private async Task RaiseEof() { _isReading = false; // Because this is an async event handler, we need to explicitly grab all the currently registered handlers, // then invoke them all and await them all. var taskList = EoFReached?.GetInvocationList().Select(h => ((Func <Task>)h)?.Invoke()); await Task.WhenAll(taskList ?? new Task[0]); }
protected virtual void OnEoFReached() { EoFReached?.Invoke(); }