2nd thread locks up 1st thread?

J

Jon Davis

I have a Windows Forms application where I normally had two threads running,
with the second thread started by a main window. The second thread ran in
the background just fine. Then I made some changes and I had the second
thread initiated in a separate window ("owned" by the first thread)--a
progress window that adds a system tray icon--and now I'm finding, whether
coincidentally or not, that the main window locks up when the second thread
is busy (waiting on a web server response). Does anybody know what some
typical causes could explain what might be causing synchronocity between two
threads? If it matters, the second thread does have delegates / events that
get sent to the main window to update the status bar, but those event
handlers don't lock up the application (they basically just update the
status bar text). That is the only thing I know of that

Thanks for any ideas...

Jon
 
J

Jon Skeet [C# MVP]

Jon Davis said:
I have a Windows Forms application where I normally had two threads running,
with the second thread started by a main window. The second thread ran in
the background just fine. Then I made some changes and I had the second
thread initiated in a separate window ("owned" by the first thread)--a
progress window that adds a system tray icon--and now I'm finding, whether
coincidentally or not, that the main window locks up when the second thread
is busy (waiting on a web server response). Does anybody know what some
typical causes could explain what might be causing synchronocity between two
threads? If it matters, the second thread does have delegates / events that
get sent to the main window to update the status bar, but those event
handlers don't lock up the application (they basically just update the
status bar text). That is the only thing I know of that

Could you produce a short but complete program that does nothing apart
from showing the problem? I find that thread problems are really hard
to find just from descriptions.
 
J

Jon Davis

oops .. lost your killfile ..


Jon Skeet said:
Could you produce a short but complete program that does nothing apart
from showing the problem? I find that thread problems are really hard
to find just from descriptions.
 
J

Jon Davis

Thanks Sami.

Jon

Sami Vaaraniemi said:
This can happen if you access a Form (or any other Windows Forms control)
from a thread other than the UI thread. To make it thread safe, call
methods/properties through Control.Invoke from other threads. This will
execute the call in the thread that owns the control.

Sami
 
S

Sami Vaaraniemi

This can happen if you access a Form (or any other Windows Forms control)
from a thread other than the UI thread. To make it thread safe, call
methods/properties through Control.Invoke from other threads. This will
execute the call in the thread that owns the control.

Sami
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top