刚刚开始学C#,有些不懂的地方,请诸位指教。下面的代码基本上是msdn的sample,但这里myProcess = Process.Start("myexe.exe");问题一:有时候myexe运行结束的太快,进入while(!myProcess.HasExited)后,但在调用myProcess.WorkingSet之前就结束了,这样会产生错误,请问应该怎么处理呢?问题二:myexe如果产生了run time error,就会有对话框弹出,而主程序也就死了,请问有什么办法可以使主程序继续运行,并可得到myexe异常退出的ExitCode,不弹出对话框呢?在vc里面好象有个SetErrorMode的方法。using System;
using System.Diagnostics;
using System.Threading;namespace Process_Sample
{
   class MyProcessClass
   {
      public static void Main()
      {
         try
         {            Process myProcess;
            myProcess = Process.Start("myexe.exe");            while(!myProcess.HasExited)
            {
               Console.WriteLine();               // Get physical memory usage of the associated process.
               Console.WriteLine("Process's physical memory usage: " + myProcess.WorkingSet);
               // Get base priority of the associated process.
               Console.WriteLine("Base priority of the associated process: " + myProcess.BasePriority);
               // Get priority class of the associated process.
               Console.WriteLine("Priority class of the associated process: " + myProcess.PriorityClass);
               // Get user processor time for this process.
               Console.WriteLine("User Processor Time: " + myProcess.UserProcessorTime);
               // Get privileged processor time for this process.
               Console.WriteLine("Privileged Processor Time: " + myProcess.PrivilegedProcessorTime);
               // Get total processor time for this process.
               Console.WriteLine("Total Processor Time: " + myProcess.TotalProcessorTime);
               // Invoke overloaded ToString function.
               Console.WriteLine("Process's Name: " + myProcess.ToString());
               Console.WriteLine("-------------------------------------");               if(myProcess.Responding)
               {
                  Console.WriteLine("Status:  Responding to user interface");
                  myProcess.Refresh();
               }
               else
               {
                  Console.WriteLine("Status:  Not Responding");
               }
               Thread.Sleep(1000);            }            Console.WriteLine();
            Console.WriteLine("Process exit code: {0}", myProcess.ExitCode);
         }
         catch(Exception e)
         {
            Console.WriteLine("The following exception was raised: " + e.Message);
         }
      }   }
}