Form created by thread not responding
-
I have a multithreaded program that draws stock market charts on as many as eight instances of a form. When I create instances of this form by clicking a menu item, they come up and are responsive to the user and the other threads. If I create a new instance from a thread other than the UI the form comes up but is not responsive to the user or the other threads. How does one do this? RCarey
-
I have a multithreaded program that draws stock market charts on as many as eight instances of a form. When I create instances of this form by clicking a menu item, they come up and are responsive to the user and the other threads. If I create a new instance from a thread other than the UI the form comes up but is not responsive to the user or the other threads. How does one do this? RCarey
The form won't work becuase it's not on the same thread as the application's message pump. Keystrokes and mouse clicks comming into the application have no way of getting to the form because they can't cros thread boundries. You have to modify your code so the form is created by the UI thread. You can still update the form from a background thread if you call BeginInvoke on the methods to need to call on the form. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
The form won't work becuase it's not on the same thread as the application's message pump. Keystrokes and mouse clicks comming into the application have no way of getting to the form because they can't cros thread boundries. You have to modify your code so the form is created by the UI thread. You can still update the form from a background thread if you call BeginInvoke on the methods to need to call on the form. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
That's where I am now. The arrival of a packet sets the text of a menu item on the main form to the stock's symbol and beeps. I have to click the menu item to create a new form. this works but when events are fast this is too slow. I tried changing the text of a label on the main form which throws an event. An event handles creates the form but it is still not responsive to the user. RCarey
-
That's where I am now. The arrival of a packet sets the text of a menu item on the main form to the stock's symbol and beeps. I have to click the menu item to create a new form. this works but when events are fast this is too slow. I tried changing the text of a label on the main form which throws an event. An event handles creates the form but it is still not responsive to the user. RCarey
RJGCarey wrote:
tried changing the text of a label on the main form which throws an event
Throws a what?? Are you saying it throws an Exception? You can't modify a control from anything other that the thread it was created on. Outside of that, you have to use BeginInvoke.
RJGCarey wrote:
An event handles creates the form but it is still not responsive to the user.
Make absolutely SURE the correct thread is executing the code to create the new Form instance. You'll probably have to put together a method to create the Form instance and use BeginInvoke to call it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome