Okay - this is what my code is trying to accomplish (in relative pseudo-code):
That is pretty much a dumb'ed down idea of how my application works... (where the thread functions OperationX will launch corresponding processes). As it is this works fine except that I am unable to find a way to WAIT for a thread to complete without holding the form itself hostage.
I tried using "thX.Join()" but this will block the UI thread until it returns (which is not ok)... while each operation is running I need the user to be able to move the window (UI) if he wants to, minimize it, or simply stare at it to see what is being done by looking at the status bar or label... But it can't look out of focus or as if it has frozen...
Any help would be much appreciated.
Thanks,
Code:
SetStatusBar("Start Operation 1");
SetLabel("Start Operation 1");
Thread th1 = new Thread (new ThreadStart(Operation1));
th1.Start();
// WAIT FOR th1 to finish without loosing focus on the UI
SetStatusBar("Operation 1 Finished");
SetLabel("Operation 1 Finished");
SetStatusBar("Start Operation 2");
SetLabel("Start Operation 2");
Thread th2 = new Thread (new ThreadStart(Operation2));
th2.Start();
// WAIT FOR th2 to finish without loosing focus on the UI
SetStatusBar("Operation 2 Finished");
SetLabel("Operation 2 Finished");
SetStatusBar("Start Operation 3");
SetLabel("Start Operation 3");
Thread th3 = new Thread (new ThreadStart(Operation3));
th3.Start();
// WAIT FOR th3 to finish without loosing focus on the UI
SetStatusBar("Operation 3 Finished");
SetLabel("Operation 3 Finished");
btnCanCloseWindow.Enabled = true; // this can only be true if all the tasks have run
That is pretty much a dumb'ed down idea of how my application works... (where the thread functions OperationX will launch corresponding processes). As it is this works fine except that I am unable to find a way to WAIT for a thread to complete without holding the form itself hostage.
I tried using "thX.Join()" but this will block the UI thread until it returns (which is not ok)... while each operation is running I need the user to be able to move the window (UI) if he wants to, minimize it, or simply stare at it to see what is being done by looking at the status bar or label... But it can't look out of focus or as if it has frozen...
Any help would be much appreciated.
Thanks,