void AddAnswer(T answer) { if (answer == null || runningQuery.IsCancellationRequested) { return; } Answers.Add(answer); if (Answers.Count >= AnswersNeeded && !runningQuery.IsCancellationRequested) { runningQuery.Cancel(false); } AnswerObtained?.Invoke(this, answer); }
/// <summary> /// Add a answer to the query. /// </summary> /// <param name="answer"> /// An answer. /// </param> /// <remarks> /// </remarks> public void AddAnswer(T answer) { if (answer == null) { return; } if (runningQuery != null && runningQuery.IsCancellationRequested) { return; } if (answers.TryAdd(answer, answer)) { if (answers.Count >= AnswersNeeded && runningQuery != null && !runningQuery.IsCancellationRequested) { runningQuery.Cancel(false); } } AnswerObtained?.Invoke(this, answer); }