Async process start and wait for it to finish

后端 未结 5 1100
小鲜肉
小鲜肉 2020-11-27 15:31

I am new to the thread model in .net. What would you use to:

  1. start a process that handles a file (process.StartInfo.FileName = fileName;)
  2. wait for th
5条回答
  •  再見小時候
    2020-11-27 16:25

    You can use the Exited event in Process class

    ProcessStartInfo info = new ProcessStartInfo();
    
    info.FileName = "notepad.exe";
    Process process = Process.Start(info);
    
    process.Exited += new EventHandler(process_Exited);
    Console.Read();
    

    and in that event you can handle the operations you mentioned

提交回复
热议问题