进程1 启动了进程2,如何实现  等进程2 执行完 再执行进程1? 进程2执行时 进程1 不动!  谢谢

解决方案 »

  1.   

    进程的话不太清楚。线程则可以通过定义信号量ManualResetEvent来处理。
      

  2.   

    启动进程之后调用WaitForExit
    将阻塞当前进程
                    exeProcess.Start();
                    exeProcess.WaitForExit();
      

  3.   

    using System;
    using System.Threading;namespace AutoResetEvent_Examples
    {
        class MyMainClass
        {
            //Initially not signaled.
          const int numIterations = 100;
          static AutoResetEvent myResetEvent = new AutoResetEvent(false);
          static int number;
          
          static void Main()
            {
             //Create and start the reader thread.
             Thread myReaderThread = new Thread(new ThreadStart(MyReadThreadProc));
             myReaderThread.Name = "ReaderThread";
             myReaderThread.Start();         for(int i = 1; i <= numIterations; i++)
             {
                Console.WriteLine("Writer thread writing value: {0}", i);
                number = i;
                
                //Signal that a value has been written.
                myResetEvent.Set();
                
                //Give the Reader thread an opportunity to act.
                Thread.Sleep(0);
             }         //Terminate the reader thread.
             myReaderThread.Abort();
          }      static void MyReadThreadProc()
          {
             while(true)
             {
                //The value will not be read until the writer has written
                // at least once since the last read.
                myResetEvent.WaitOne();
                Console.WriteLine("{0} reading value: {1}", Thread.CurrentThread.Name, number);
             }
          }
        }
    }
      

  4.   

    这个我用一个label可以实现。但是觉得不是很好。我想应该有个东西   可以监视 某个变量  或者某个进程  ,当 变量  或进程  发生改变    这个东西可以 监视到。谢谢
      

  5.   

    sorry,没看清楚……
    重贴
      

  6.   

    忽然想到个很简单的方法windows message,娃哈哈哈
      

  7.   

    好久没做VC++了,居然把windows message给忘了。举个例子:不同的process有不同的handler,right? e.g.: 
    ProcessName   ProcessHandler
      ProcA             0x1027
      ProcB             0x0f34
    基本方法
    1. ProcA里面启动ProcB,同时把ProcA的handler传给ProcB
    2. ProcB做完后给ProcA PostMessage 
        [DllImport("user32")]
        private static extern IntPtr PostMessage (IntPtr hwnd, int wMsg, int wParam, int lParam);
    3. ProcA只要对这个Message做相应就行了
        protected override void WndProc(ref Message m)