public static void MSMQMian() { MSMQ.Createqueue(".\\Private$\\myQueue"); MSMQA(); MSMQB(); Console.WriteLine("MSMQ结束"); }
private static async void MSMQB() { var task = Task.Run(() => { for (int i = 0; i < 20; i++) { MSMQ.SendMessage("MSMQB" + i); } }); await task; Console.WriteLine("MSMQB发送完成,进行读取:"); while (MSMQ.GetMessageCount() > 0) { MSMQ.ReceiveMessage(); } }