A
Axel Dahmen
Hi,
I've two threads in my program: 1) The original program thread and 2) a
worker thread.
For simplicity my worker thread writes its output into the static controls
and status bar by itself.
In the Form_Closing() event, I want to shut down my worker thread gracefully
and wait for its completion (see code #1 below). The while loop at the end
of Form_Closing() never exits, apparently because in my worker thread hangs
updating a status bar panel. It appears to me that updating the status bar
during executing the Form_Closing() event won't work.
What should I do?
How can I trigger some event in the original thread to have the status bar
updated from there?
TIA,
Axel Dahmen
------
code #1:
private void MainForm_Closing(...)
{
if (m_running) m_running=false; // semaphore. Ends while-loop in 2nd
thread
while (m_thread!=null && m_thread.IsAlive) Thread.Sleep(100);
}
I've two threads in my program: 1) The original program thread and 2) a
worker thread.
For simplicity my worker thread writes its output into the static controls
and status bar by itself.
In the Form_Closing() event, I want to shut down my worker thread gracefully
and wait for its completion (see code #1 below). The while loop at the end
of Form_Closing() never exits, apparently because in my worker thread hangs
updating a status bar panel. It appears to me that updating the status bar
during executing the Form_Closing() event won't work.
What should I do?
How can I trigger some event in the original thread to have the status bar
updated from there?
TIA,
Axel Dahmen
------
code #1:
private void MainForm_Closing(...)
{
if (m_running) m_running=false; // semaphore. Ends while-loop in 2nd
thread
while (m_thread!=null && m_thread.IsAlive) Thread.Sleep(100);
}