跟踪另一个应用程序
问题的出现原因:主应用程序需要在另一个应用程序关闭时调用一个事件,但是不想让主应用程序等待。
解决方法:使用进程的Exited事件而不是使用线程来避免阻塞程序。
文章内容如下:
Dim Process As Process = new Process() Process.StartInfo = new ProcessStartInfo("notepad", "C:\test.txt") Process.Start() Process.WaitForExit() // Do something Thanks, but I don't want the main application to have to wait. I just want it to call an event once notepad closes. What was the purpose of the @? You noticed that before I rolled it back huh? Sorry about that! It's a C# thing, which I thought would be the same in VB. It isn't: How to do a verbatim string literal in VB.NET? If you don't want to block the program you can use the Process.Exited event rather than using threads. Lol, good spot! (In case you hadn't already noticed, C# and VB are basically identical, ignoring these little differences)
文章结束。