I have a ProgressRing in a Page in WPF that needs to be displayed while the Grid is loading (Purpose: Show the user who is loading) and then be deactivated when the load of the Grid is completed. But it is giving this error:
public ClienteListPage()
{
InitializeComponent();
carregar();
}
public void carregar()
{
prProgresso.IsActive = true;
Task.Factory.StartNew(() =>
{
DataContext = App.container.GetService<IClientesListarController>();
}).ContinueWith(task =>
{
prProgresso.IsActive = false;
if (task.IsFaulted)
{
Console.WriteLine("{0} Exception caught.", task.Exception);
MessageBox.Show("Error");
}
}, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
}