args)
2 {
3 var messagesReceived = 0;
4 var maxMessage = 5;
5 var channelName = \"幸福框架\";
6
7 using (var redisConsumer = new RedisClient())
8 {
9 using (var subscription = redisConsumer.CreateSubscription())10 {11 subscription.OnSubscribe = channel =>12 {13 Console.WriteLine(String.Format(\"订阅频道:'{0'\" channel));14 ;15 subscription.OnUnSubscribe = channel =>16 {17 Console.WriteLine(String.Format(\"取消订阅频道:'{0'\" channel));18 ;19 subscription.OnMessage = (channel msg) =>20 {21 Console.WriteLine(String.Format(\"从频道:'{0'获取了消息:'{1'\" channel msg));22 23 if (++messagesReceived == maxMessage)24 {25 subscription.UnSubscribeFromAllChannels();26 27 ;28 29 ThreadPool.QueueUserWorkItem(x =>30 {31 Thread.Sleep(200);32 Console.WriteLine(\"开始发布消息\");33 34 using (var redisPublisher = new RedisClient())35 {36 for (var i = 1; i <= 5; i++)37 {38 var message = \"段光伟:\" + DateTime.Now;39 Console.WriteLine(String.Format(\"发布消息:'{0'到频道:'{1'\" message channelName));40 redisPublisher.PublishMessage(channelName message);41 42 43 );44 45 Console.WriteLine(String.Format(\"开始监听频道:'{0'\" channelName));46 subscription.SubscribeToChannels(channelName); //blocking47 48 49
- 魅族|魅族正统在OPPO?前工程师跳槽负责Color OS,重点解决杀后台!
- tiktok|TikTok的介绍、发展历史、 在全球的表现。
- 麒麟980|华为麒麟980跟990在性能上差距大不大?
- 微信“电子身份证”来了,快领取
- 华为|曝华为Mate X3发布会已在准备中:麒麟9000 4G加持
- 台积电开始“担心”了!三大调整的背后,是华为造成的影响!
- A轮融资|物联网设备智能感应,飞睿智能毫米波雷达技术,存在感应雷达模组应用
- 无人机|支持全自动起降!大疆首款机场发布:顶配套装卖14.98万
- A轮融资|如何在facebook做免费的营销?
- 台积电|真的是一个“陷阱”?老美已经开始行动了,台积电被排除在外!