c# - Move Slider until Value is reached -


i try "animate" slider while value true, until reaches designated value. reason not work easy thought:

while (depthscan == true) {     depth_max_slider.value += 10;     console.writeline("working");     if (blobcount <= 400)     {         depth_max_slider.value += 10;      }     else     {         depthscan = false;     }  } 

what doing wrong?

something should trick...

public class mywindow : window     {         void startbutton_click( object sender, routedeventargs e )         {             // method run on ui thread              backgroundworker worker = new backgroundworker();              worker.dowork += worker_dowork;             worker.workerreportsprogress = true;             worker.progresschanged += worker_progresschanged;              worker.runworkerasync(); // start thread              // ui thread continues              // exit click event handler, ui thread goes wpf control can keep rendering...         }          void worker_progresschanged( object sender, progresschangedeventargs e )         {             // method run on ui thread              double depth_max = (double) e.userstate; // grab value of depth_max passed on background thread              depth_max_slider.value = depth_max; // update slider value              // exit progresschanged event handler, ui thread goes wpf control can keep rendering...         }          void worker_dowork( object sender, doworkeventargs e )         {             // method run on background thread              backgroundworker worker = sender backgroundworker;              int percentcomplete = 0;             double depth_max;              while( depthscan == true )             {                 depth_max += 10; // note: don't touch slider control background thread, use double instead!                  worker.reportprogress( percentcomplete, depth_max ); // pass depth_max 2nd param, "user state", show in progresschangedeventargs in progresschanged handler                  console.writeline( "working" );                 if( blobcount <= 400 )                 {                     depth_max += 10;                      worker.reportprogress( percentcomplete, depth_max );                  }                 else                 {                     depthscan = false;                 }              }         }     } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -