My question has such a scenario:
Two threads, thread1(e.g. UI thread in WPF) and thread2,
thread1 starts thread2 in threadpool and returns to handle other UI events. What thread2 does is to start a process until complete, then notify thread1 it is done, returns an exitcode to thread1.
The problem is how to make thread1 do other things while thread2 is busy with some computation, but responds immediately when the process in thread2 returns.
public class Window1:Window
{
onbuttonrunclick()
{
start thread2
}
.....
}
thread2
{
create WorkProcess.
WorkProcess.start();
WorkProcess.waitforexit();
}
Even further, is it possible get rid of thread2, and use some inter-process communication mechanism to notify UI the exitcode of the WorkProcess.
Any suggestion is greatly appreciated.