In my wpf (C #) application, a lengthy process is executed when the user clicks a button. When the button is pressed until the full code is executed, the window freezes and the user cannot complete any other task in the window. How can I make a button code by pressing a button as a background process so that the window becomes responsive to the user. I tried the following method, but was unsuccessful.
private void btn_convert_Click(object sender, RoutedEventArgs e)
{
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
new Action(() => {
WorkerMethod();
}));
}
Where WorkerMethod is a function with all the code. Any suggestions.
Regards,
Sangeetha
source
share