0

Currently, I am programming an application and need to call an exe file to process images. However, this exe file takes a long time to process, if I use WaitForExit, the entire software will not be able to perform operations with the form. So I am posting this article in the hope that someone can help me so that I can wait for the exe file to finish processing without having the above situation. Updated: If I use multi-thread for this application, the exe file use all of the computer's memory

  • Probably a lot of technologies would work: Background Worker, Tasks, Threadpool. [Tasks](https://learn.microsoft.com/en-us/dotnet/standard/parallel-programming/task-based-asynchronous-programming) would be the most modern approach, I guess. – Uwe Keim Jun 10 '22 at 07:10
  • @UweKeim I known that but I have another problem. That is if I run multithread, the exe file will use all of memory on computer and the computer will be crash. So Tasks can't be use and I want that when a first task finished, the next task will start. – Bảo Hoàng Jun 10 '22 at 07:18
  • You could make use of the 'Exited' event for the process. See https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.exited?view=net-6.0 for an example. – Johan Donne Jun 10 '22 at 07:24
  • 1
    Without _any_ code, it is hard to assess any potential for improvement or solution to your specific problem. – Fildor Jun 10 '22 at 07:26
  • 1
    ` Tasks can't be used` that's wrong. It's not tasks that waste memory, it's the application's inefficient code. **Everyone** uses tasks in 2022. If you use HttpClient or any async call you're using tasks. Even if you block those tasks using `.Wait()` or `.Result` – Panagiotis Kanavos Jun 10 '22 at 07:52

0 Answers0