private async Task ProcessSendFatalAlert(Alert alert, CancellationToken token) { this.logger?.Warn("Processing fatal alert..."); try { // Create and encrypt the alert record Record record = new Record(RecordType.Alert, this._handshakeSession.NegotiatedVersion, alert.GetBytes()); this._recordHandler.ProcessOutputRecord(record); // Attempt sending the alert record await this._recordStream.SendAsync(new Record[] { record }, token); } catch (Exception ex) { this.logger?.Error("Processing fatal alert failed: {0}", ex.Message); } finally { if (this._recordStream != null) { this.logger?.Info("Closing record stream..."); this._recordStream.Flush(); this._recordStream.Close(); } } }