Theading problem
-
Dear all, Could anyone please help me with the following problem. I have a MainForm in my application. I call a background worker thread to do some work. This thread never finishes, so it will always run in the background and will be closed when the application closes. This works perfect. Then I open a new form from my main thread and in that form I call another backgroundworker. As long as backgroundworker 2 is running, backgroundworker 1 becomes unresponsive. The MainForm stays responsive, the newly opened form stays responsive, but the two backgroundworkers don't seem to like each other and seems to be competing over resources. * MainForm - backgroundworker 1 * subForm - backgroundworker 2 When backgroundworker 2 is running, backgroundworker 1 becomes unresponsive until backgroundworker 2 is finished. Weird huh ? Kind regards,
-
Dear all, Could anyone please help me with the following problem. I have a MainForm in my application. I call a background worker thread to do some work. This thread never finishes, so it will always run in the background and will be closed when the application closes. This works perfect. Then I open a new form from my main thread and in that form I call another backgroundworker. As long as backgroundworker 2 is running, backgroundworker 1 becomes unresponsive. The MainForm stays responsive, the newly opened form stays responsive, but the two backgroundworkers don't seem to like each other and seems to be competing over resources. * MainForm - backgroundworker 1 * subForm - backgroundworker 2 When backgroundworker 2 is running, backgroundworker 1 becomes unresponsive until backgroundworker 2 is finished. Weird huh ? Kind regards,
Rick van Woudenberg wrote:
Weird huh ?
No. It's called a race condition and is a common problem when novices try multi-threaded programming What are these threads doing? Are they trying to utilize the same resources? http://msdn.microsoft.com/en-us/library/1c9txz50.aspx[^]
only two letters away from being an asset