private Task ProcessIncomingMessage(MessageReceivedEventArgs e) { try { var expected = this.logReader.GetPayload(); // We're converting to XML and back again to normalize the payload. This could be done much more // efficiently by a dedicated method, which has yet to be implemented. var actualXml = this.ToXml(e.GetPayload()); var actual = this.FromXml(actualXml); if (!expected.SequenceEqual(actual)) { var msg = "The expected payload does not match the actual received payload, see Data for details."; var expectedXml = this.ToXml(expected); throw new S101Exception(msg) { Data = { { "Expected", expectedXml }, { "Actual", actualXml } } }; } } catch (Exception ex) { this.done.TrySetException(ex); return Task.FromResult(false); } return this.SendMessagesAsync(); }
private async void OnClientEmberDataReceived(object sender, MessageReceivedEventArgs e) { await this.taskQueue.Enqueue(() => this.ProcessIncomingMessage(e)); }