Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: BusyIndicator Not Visible

$
0
0
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 :
 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;
      } ) );  
}

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>