I have C# WPF application which reads data from database then does some work. But the problem is when I am reading data my UI doesn't respond. I have tried Tasks and dispatcher. None of them helps. Code below is in the button_click event. Here is code:
DataSet ds;
DataTable dt = new DataTable();
Task myTask = new Task(new Action(() =>
{
//GetMyDataSet() returns DataSet
ds = GetMyDataSet();
dt = ds.Tables["MyTableName"];
}));
myTask.Start();
while (!myTask.IsCompleted)
{
System.Threading.Thread.Sleep(1000);
}
//Continue
BackgroundWorker.