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); }