private async void POEStash_OnStashUpdated(object sender, SnapShotEventArgs e) { //Save the last received snapshot ID LastReceivedSnapshotId = e.Snapshot.Id; TrainingCycleResult result; if (ContinuationEndpoint == null) { ContinuationEndpoint = Task.Run(() => PerformCycle(e.Snapshot)); result = await ContinuationEndpoint; } else { //A task is already running, continue with the new task. ContinuationEndpoint = ContinuationEndpoint.ContinueWith((p) => PerformCycle(e.Snapshot)); result = await ContinuationEndpoint; } //Check for aborted if (result == TrainingCycleResult.ABORTED) { return; } lastCycleResult = result; }
public NetworkTrainer(ConversionTable table) { this.conversionTable = table; this.lastCycleResult = new TrainingCycleResult(SupportedItemTypes); POEStash.OnStashUpdated += POEStash_OnStashUpdated; }