private static void ReadLoop(IMsmqConnection connection, CancellationToken cancellationToken) { Console.WriteLine("Enter your text message and press ENTER..."); while (!cancellationToken.IsCancellationRequested) { // read a text message from the user cancellationToken.ThrowIfCancellationRequested(); var text = Console.ReadLine(); // send the text message to the queue cancellationToken.ThrowIfCancellationRequested(); if (!string.IsNullOrEmpty(text)) { connection.SendText(text); } } }
public MsmqService(ILogger <MsmqService> logger, IMsmqConnection connection, IMsmqProcessor processor) { Logger = logger ?? throw new ArgumentNullException(nameof(logger)); Connection = connection ?? throw new ArgumentNullException(nameof(connection)); Processor = processor ?? throw new ArgumentNullException(nameof(processor)); }