0
Windows 7家庭高级版
Visual Basic“暂停”执行,但保持事件处理程序运行?
有没有办法暂停执行程序,但保持事件处理程序运行?
我的Visual Basic控制台应用程序监视文件事件,并使用熟悉的事件处理程序处理事件。
当前算法:
1.创建FileSystemWatcher的
2.设置事件处理程序
3.等待来自用户,然后退出控制台输入。
我可以使用系统调用来替换最后一步,以暂停执行前台,而事件处理程序继续对事件做出反应吗?
下面是代码大纲(删除了很多行)。
Dim watcher As New FileSystemWatcher() 'Create a new FileSystemWatcher
AddHandler watcher.Changed, AddressOf OnChanged 'Add event handler
watcher.EnableRaisingEvents = True 'Begin watching
'I wish to replace this with a system call to suspend
'execution, but keep the event handlers running.
While Chr(Console.Read()) <> "q"c 'Wait for the user to quit
End While
我想你真正需要的是如何创建一个后台进程? –