public void Execute() { QueueHandler.InitializeQueue(); DateTime startTime = DateTime.Now; Console.WriteLine($"Starting to upload {_numberOfMessages} messages to queue."); for (int messagesSent = 1; messagesSent <= _numberOfMessages; messagesSent++) { Message message = new Message(); message.Body = SettingsProvider.GetMessageBody(); message.Label = "Sent from MsmqTester"; message.TimeToReachQueue = new TimeSpan(0, 5, 0); message.UseDeadLetterQueue = true; message.Recoverable = SettingsProvider.GetWillPersist(); message.UseJournalQueue = false; QueueHandler.SendMessage(message); Console.WriteLine($"Uploaded message {messagesSent}"); } Console.WriteLine($"Uploaded all {_numberOfMessages} to the queue."); DateTime endTime = DateTime.Now; Console.WriteLine($"Started {startTime} and Ended {endTime}. Duration = {endTime - startTime}"); QueueHandler.CloseAndDispose(); }