Hi,
Interacting with UI in the BackgroundWorker will not work :
"You must be careful not to manipulate any user-interface objects in your DoWork event handler. Instead, communicate to the user interface through the ProgressChanged and RunWorkerCompleted events."
From
"http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(v=vs.110).aspx"
Maybe you can create a new thread :
Interacting with UI in the BackgroundWorker will not work :
"You must be careful not to manipulate any user-interface objects in your DoWork event handler. Instead, communicate to the user interface through the ProgressChanged and RunWorkerCompleted events."
From
"http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(v=vs.110).aspx"
Maybe you can create a new thread :
private void Button_Click( object sender, RoutedEventArgs e )
{
_busyIndicator.IsBusy = true;
Thread t = new Thread( () => this.CopyFiles( _busyIndicator ) );
t.Start();
}
private void CopyFiles( BusyIndicator busyIndicator )
{
System.Diagnostics.Debug.WriteLine("Start Copy");
int half = int.MaxValue / 2;
for( int i = 0; i < int.MaxValue; ++i )
{
int x = 0;
if( i == half )
{
this.Dispatcher.Invoke((Action)(() =>
{
//Do UI Stuff
Xceed.Wpf.Toolkit.MessageBox.Show( "My Message Box" );
}));
}
}
System.Diagnostics.Debug.WriteLine( "End Copy" );
//Stop BusyIndicator on UI Thread
this.Dispatcher.Invoke( ( Action )( () =>
{
busyIndicator.IsBusy = false;
} ) );
}