如果你需要的是通知对方已经完成了它的任务,一个应用程序,最简单的方法是使用一个命名的EventWaitHandle。该对象在其无信号状态下创建。第一个应用在手柄上等待,第二个应用在完成任务时发出信号。例如:
// First application
EventWaitHandle waitForSignal = new EventWaitHandle(false, EventResetMode.ManualReset, "MyWaitHandle");
// Here, the first application does whatever initialization it can.
// Then it waits for the handle to be signaled:
// The program will block until somebody signals the handle.
waitForSignal.WaitOne();
设置第一个等待同步的程序。第二个应用程序也同样简单:
// Second app
EventWaitHandle doneWithInit = new EventWaitHandle(false, EventResetMode.ManualReset, "MyWaitHandle");
// Here, the second application initializes what it needs to.
// When it's done, it signals the wait handle:
doneWithInit.Set();
当第二个应用程序调用集合,它标志着事件和第一个应用程序将继续进行。
这听起来很好。将立即测试,并返回这里:) – 2009-01-27 08:13:25