AsyncCallback threading issue
-
Im trying to access a listbox control located on my main form inside an AsyncCallback method and getting cross thread errors as AsyncCallback is on a seperate thread. I decided then to create a new delagate and fire an event from within the AsyncCallback method thinking this would solve the problem but that too was executed on a seperate thread. How can i fire an event from inside the method that runs on the main thread? thankyou.
-
Im trying to access a listbox control located on my main form inside an AsyncCallback method and getting cross thread errors as AsyncCallback is on a seperate thread. I decided then to create a new delagate and fire an event from within the AsyncCallback method thinking this would solve the problem but that too was executed on a seperate thread. How can i fire an event from inside the method that runs on the main thread? thankyou.
Hi, as always, GUI components need to be handled by the GUI thread; COntrol.InvokeRequired, and Control.Invoke() take care of that. There are plenty of examples everywhere. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
Hi, as always, GUI components need to be handled by the GUI thread; COntrol.InvokeRequired, and Control.Invoke() take care of that. There are plenty of examples everywhere. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.