private async void Compute() { Computing = true; await TestBench.ComputeIfNeededAsync(default(CancellationToken)); if (TestBench.Structure.IsValid) { SetAllQuickValues(); } Computing = false; }
private async void TestBench_PropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case "Name": TitleText = TestBench.Name; SaveTestBench(); break; case "NeedsCompute": if (TestBench.NeedsCompute) { if (tokenSource != null) { tokenSource.Cancel(); } tokenSource = new CancellationTokenSource(); Computing = true; await TestBench.ComputeIfNeededAsync(tokenSource.Token); if (tokenSource.IsCancellationRequested) { return; } SetAllQuickValues(); SaveTestBench(); Computing = false; } break; case "NoSolution": NoSolution = TestBench.NoSolution; break; case "Steps": UpdatePlot(); break; case "CurrentIndex": CstackText = TestBench.CurrentStructure .StackCapacitance.MicroFaradsPerSquareCentimeterToString("{0:F3} μF/cm\xB2"); break; } }