Reputation: 18511
What is the best practice to invoke a method in a different thread from a winform button so the ui doesn't freeze or creates a delay?
Upvotes: 2
Views: 7278
Reputation: 45071
In a first step start with
If this doesn't meet your requirements or you need more advanced stuff you should take a look into one of these:
Upvotes: 6
Reputation: 8937
You can do like this
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
{
//DO SOMETHING
}
Upvotes: -1
Reputation: 23675
You should call Control.Invoke
or BeginInvoke
, see in-depth reference here.
Upvotes: 0