I have a Task that returns an ObservableCollection of Companies. I display a small Window that simply says "Please wait.." whilst this Task is performed. The problem is, the user can still interact with the UI when this Task is running. I need to lock down the UI until this has completed.
Here is the code I have used so far;
private async void FillDataGrid()
{var Companies = new ObservableCollection<CompanyModel>(); var waitWindow = new PleaseWait(); waitWindow.Show(); Companies = await ReturnCompanies(); CompanyICollectionView = CollectionViewSource.GetDefaultView(Companies); DataContext = this; waitWindow.Close();
}
private Task<ObservableCollection<CompanyModel>> ReturnCompanies() { try { var _cDS = new CompanyDataService(); return Task.Run(() => { return _cDS.HandleCompanySelect(); }); } catch (Exception ex) { var hEs = new HandleExceptionService(); hEs.HandleException(ex.ToString()); return null; } }How can I prevent the user from interacting with the UI whilst this Task is running?