public static async void QueueB() { QueueWork queueTest = new QueueWork(); var task = Task.Run(() => { for (int i = 0; i < 20; i++) { queueTest.IntoData("Queue-B" + i); } }); await task; Console.WriteLine("Queue-B插入完成,进行输出:"); while (queueTest.GetCount() > 0) { queueTest.OutData(); } }
public static async void MSMQA() { queueWork = new QueueWork(); var task = Task.Run(() => { for (int i = 0; i < 20; i++) { //queueWork.Createqueue(queuePath); string sendMsg = queueWork.SendMessage($"MSMQ-A{i}", queuePath); Console.WriteLine(sendMsg); } }); await task; Console.WriteLine("MSMQA发送完成,进行读取:"); while (queueWork.GetMessageCount(queuePath) > 0) { string receiveMsg = queueWork.ReceiveMessage(queuePath); Console.WriteLine(receiveMsg); } }