void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.startstop = ((System.Windows.Controls.Button)(target)); #line 27 "..\..\MainWindow2.xaml" this.startstop.Click += new System.Windows.RoutedEventHandler(this.startstop_Click); #line default #line hidden return; case 2: this.reset = ((System.Windows.Controls.Button)(target)); #line 28 "..\..\MainWindow2.xaml" this.reset.Click += new System.Windows.RoutedEventHandler(this.reset_Click); #line default #line hidden return; case 3: this.useInterrupt = ((System.Windows.Controls.CheckBox)(target)); return; case 4: this.status = ((System.Windows.Controls.TextBlock)(target)); return; case 5: this.quad1 = ((MutexDemo.QuadrantView)(target)); return; case 6: this.quad2 = ((MutexDemo.QuadrantView)(target)); return; case 7: this.quad3 = ((MutexDemo.QuadrantView)(target)); return; case 8: this.quad4 = ((MutexDemo.QuadrantView)(target)); return; } this._contentLoaded = true; }
private void UpdateQuadrant(int quadrant, double sum, int nCycles) { QuadrantView qv = null; switch (quadrant) { case 0: qv = quad1; break; case 1: qv = quad2; break; case 2: qv = quad3; break; case 3: qv = quad4; break; } void doUpdate() { status.Text = $"{_taskRunner.TotalCycles} Cycles Completed"; qv.UpdateProgress(sum, nCycles); } // We cannot "touch" UI objects directly from a non-UI thread. // Dispatcher.Invoke will do the update on the UI thread. Dispatcher.Invoke(doUpdate); }
private void UpdateQuadrant(int quadrant, double sum, int nCycles) { QuadrantView quadrantView = null; switch (quadrant) { case 0: quadrantView = quad1; break; case 1: quadrantView = quad2; break; case 2: quadrantView = quad3; break; case 3: quadrantView = quad4; break; } void doUpdate() // local method { status.Text = $"{Interlocked.Read(ref totalCycles)} Cycles Completed"; quadrantView.UpdateProgress(sum, nCycles); } // We cannot "touch" UI objects directly from a non-UI thread. // Dispatcher.Invoke will do the update on the UI thread. Dispatcher.Invoke(doUpdate); }