Reputation: 4951
I have a Winforms application that hosts a WCF service.
Inside my Connect
button click event, the connection is opening via BackgroundWorker
in order to my UI responding while this connect s still in process (1 - 2 seconds) and after BackgroundWorker_RunWorkerCompleted
event go to my other class and do my stuff.
Recently I added few Thread.Sleep
while debugging and notice that it does not freeze my UI so after I search I found that is maybe because of the BackgroundWorker
thread (am I right ?)
In my application I have the form class and another class that contain several events, the form class subscribe to those event and update my UI in this way:
this.Invoke((MethodInvoker)delegate
{
// Update UI
});
So my question is: is it OK to use another thread in this way and to use this.Invoke
?
Or do I need to do it in another way ?
Upvotes: 1
Views: 65