async Task Worker() { await startEvent.Task; long startPosition = 0; bool startPositionValid = false; if (options.StartPositions != null) { startPositionValid = options.StartPositions.TryGetValue(logSource, out startPosition); } using (var cancellation = CancellationTokenSource.CreateLinkedTokenSource(cancellations.ToArray())) using (var progressSink = new Progress.MultiplexingProgressEventsSink(progressSinks)) { await logSource.Provider.Search( new SearchAllOccurencesParams(options.Filters, options.SearchInRawText, startPositionValid ? startPosition : new long?()), (msg) => { Func <SearchResultMessage, bool> callback; var callbackKey = new NullableDictionaryKey <IFilter>(msg.FilteringResult.Filter); if (callbacks.TryGetValue(callbackKey, out callback) && !callback(msg)) { callbacks.Remove(callbackKey); } return(callbacks.Count > 0); }, cancellation.Token, progress : progressSink ); } }
int IEqualityComparer <NullableDictionaryKey <T> > .GetHashCode(NullableDictionaryKey <T> obj) { return(obj.Value?.GetHashCode() ?? 0); }
bool IEqualityComparer <NullableDictionaryKey <T> > .Equals(NullableDictionaryKey <T> x, NullableDictionaryKey <T> y) { return(x.Value == y.Value); }