static void Main(string[] args) { Parallel.For(0, RabbitMQConfig.ThreadCount, i => { IMessageCustomer customer = new MessageCustomer("test"); customer.StartListening(); customer.ReceiveMessageCallback = message => { Console.WriteLine("接收到消息:" + message); return(true); }; }); Console.Read(); }
static void Main(string[] args) { while (true) { IMessageCustomer customer = new MessageCustomer("test"); customer.StartListening(); customer.ReceiveMessageCallback = message => { Console.WriteLine("接收到消息:" + message); return(false); }; Thread.Sleep(2000); } Console.Read(); }