I am trying to use the ProgressBarCircular from Xceed.WpfToolKit without success.
I followed the following question to help me make it work : C# WPF Indeterminate progress bar
so my code now looks like that :
private async void ConvertButton_Click(object sender, RoutedEventArgs e)
{
this.ProgressBar.IsIndeterminate = true;
await DoWorkAsync();
this.ProgressBar.IsIndeterminate = false;
}
private async Task DoWorkAsync()
{
await Task.Run(() =>
{
this.Dispatcher.Invoke(() =>
{
// do my work (using my WPF mainWindow Fields)
});
});
}
However I keep having the Exception :
Object reference not set to an instance of an object
on the line
this.ProgressBar.IsIndeterminate = false;
Seeing how I declare ProgressBar in my xaml file and the line
this.ProgressBar.IsIndeterminate = true;
works perfectly fine (and if IsIndeterminate = false is declared before it is set to true, I have no problem either), I don't understand what might cause this exception.
Solution
It turned out that I was using some others UI's value (like TextBox.Text) in my DoWorkAsync functions and I was not using Thread.Sleep(1000) in the function as well, so ProgressBar.IsIndeterminate did not have time to change its value twice and thus threw the exception