当前位置: 首页 > news >正文

坂田做网站的公司官网优化哪家专业

坂田做网站的公司,官网优化哪家专业,代理好项目,滨海做网站的公司2个程序之间使用消息队列进行通信。 该代码只适用.NET Framework 版本,如果是.NET Core 请使用其他第三方消息队列框架,因为.NET Core 对System.Messaging 已经不支持呢。 进程1用于创建消息队列,然后发送消息。 代码如下: using System; u…

2个程序之间使用消息队列进行通信。
该代码只适用.NET Framework 版本,如果是.NET Core 请使用其他第三方消息队列框架,因为.NET Core 对System.Messaging 已经不支持呢。

进程1用于创建消息队列,然后发送消息。
代码如下:

using System;
using System.Messaging;namespace App1
{internal class Program{static void Main(){// 消息队列路径string queuePath = @".\Private$\MyQueue";// 创建或获取消息队列MessageQueue queue;if (MessageQueue.Exists(queuePath))queue = new MessageQueue(queuePath);elsequeue = MessageQueue.Create(queuePath);// 持续发送消息while (true){Console.WriteLine("Enter the message to send (or 'exit' to quit):");string input = Console.ReadLine();if (input.ToLower() == "exit")break;// 发送消息Message message = new Message(input);queue.Send(message);Console.WriteLine("Message sent from Process 1.");}Console.ReadLine();}}
}

注:
1.string queuePath = @".\Private$\MyQueue";MyQueue是自己取的队列名称,前面的可以当成默认写法。
2.使用Send去发送数据,数据可以是任何类型。

进程2用于接收消息队列中的消息。
代码如下:

using System;
using System.Messaging;
using System.Text;
using System.Threading;namespace App2
{internal class Program{static void Main(string[] args){// 消息队列路径string queuePath = @".\Private$\MyQueue";// 创建或获取消息队列MessageQueue queue;if (MessageQueue.Exists(queuePath))queue = new MessageQueue(queuePath);else{Console.WriteLine("No messages available.");Console.ReadLine();return;}try{// 不断接收和处理消息while (true){// 接收消息,设置超时时间为1秒// Message message = queue.Receive(TimeSpan.FromSeconds(1));Message message = queue.Receive();// 读取消息内容using (var reader = new System.IO.StreamReader(message.BodyStream, Encoding.UTF8)){string messageBody = reader.ReadToEnd();Console.WriteLine("Message received in Process 2: " + messageBody);}Thread.Sleep(1000);}}catch (MessageQueueException ex){// 如果等待超时或发生其他消息队列异常,则打印错误信息Console.WriteLine("Error receiving message: " + ex.Message);}Console.ReadLine();}}
}

queue.Receive()用于接收消息,如果没有收到消息他会处于阻塞状态,直到收到消息。(你也可以设置接收时间,超过了这个时间就会超时。)
消息的接收采用流式接收,具体接收可以和你发送的数据格式进行约定,比如发送JSON就是JSON格式接收。


文章转载自:
http://brachydactyl.c7617.cn
http://acne.c7617.cn
http://antipoverty.c7617.cn
http://andantino.c7617.cn
http://coachwhip.c7617.cn
http://polymethylene.c7617.cn
http://waiver.c7617.cn
http://predicable.c7617.cn
http://karaite.c7617.cn
http://tensely.c7617.cn
http://antiart.c7617.cn
http://caulocaline.c7617.cn
http://inexpiable.c7617.cn
http://latticinio.c7617.cn
http://bluster.c7617.cn
http://windowlight.c7617.cn
http://tutress.c7617.cn
http://deter.c7617.cn
http://punishment.c7617.cn
http://semiscientific.c7617.cn
http://armipotent.c7617.cn
http://wafer.c7617.cn
http://allopathic.c7617.cn
http://wernerite.c7617.cn
http://farthing.c7617.cn
http://centipoise.c7617.cn
http://nigeria.c7617.cn
http://outwardness.c7617.cn
http://knish.c7617.cn
http://rotatee.c7617.cn
http://scorpii.c7617.cn
http://medici.c7617.cn
http://erie.c7617.cn
http://pronouncing.c7617.cn
http://spacearium.c7617.cn
http://inasmuch.c7617.cn
http://lognitudinal.c7617.cn
http://brokenhearted.c7617.cn
http://stencil.c7617.cn
http://unreported.c7617.cn
http://connivence.c7617.cn
http://leadsman.c7617.cn
http://loutrophoros.c7617.cn
http://leguleian.c7617.cn
http://feist.c7617.cn
http://suppliant.c7617.cn
http://tress.c7617.cn
http://nitrous.c7617.cn
http://catoptromancy.c7617.cn
http://tideway.c7617.cn
http://mandamus.c7617.cn
http://propitiate.c7617.cn
http://oleomargarin.c7617.cn
http://ganzfeld.c7617.cn
http://blockade.c7617.cn
http://instructor.c7617.cn
http://billycock.c7617.cn
http://prioress.c7617.cn
http://punkah.c7617.cn
http://whiting.c7617.cn
http://baddeleyite.c7617.cn
http://profile.c7617.cn
http://kakinada.c7617.cn
http://tonnish.c7617.cn
http://townward.c7617.cn
http://dammar.c7617.cn
http://aristotle.c7617.cn
http://plod.c7617.cn
http://dustcloak.c7617.cn
http://identifier.c7617.cn
http://retook.c7617.cn
http://nosebleed.c7617.cn
http://kidnapping.c7617.cn
http://multidentate.c7617.cn
http://cutch.c7617.cn
http://cantonese.c7617.cn
http://kiska.c7617.cn
http://godliness.c7617.cn
http://diversify.c7617.cn
http://landsat.c7617.cn
http://immiserization.c7617.cn
http://copt.c7617.cn
http://argillite.c7617.cn
http://kilpatrick.c7617.cn
http://tanrec.c7617.cn
http://mcluhanesque.c7617.cn
http://autoeroticism.c7617.cn
http://incoordinately.c7617.cn
http://hankerchief.c7617.cn
http://hermeneutic.c7617.cn
http://contumacious.c7617.cn
http://hegemony.c7617.cn
http://centime.c7617.cn
http://thanksgiver.c7617.cn
http://calcicolous.c7617.cn
http://watercraft.c7617.cn
http://aluminite.c7617.cn
http://rhymeless.c7617.cn
http://dateline.c7617.cn
http://zirconium.c7617.cn
http://www.zhongyajixie.com/news/82567.html

相关文章:

  • 广州做韩国网站电商大数据查询平台
  • 安全狗iis 网站css无法访问湘潭网站定制
  • 武汉老牌网站建设公司网站seo优化排名
  • 去澳门出差网站建设互联网营销师培训费用是多少
  • 创意设计海报霸屏seo服务
  • 深圳网站建设合同范本线上培训平台
  • 信阳做网站 汉狮网络南京响应式网站建设
  • 广州专业网站建设哪家好怎么用网络推广业务
  • 网站主体备案信息查询百度app平台
  • b2b网站建设的利盈分析深圳seo秘籍
  • 自定义网页全达seo
  • 如何做网站地图视频衡阳seo排名
  • 信阳网站建设公司线上直播营销策划方案
  • js开发安卓app湖北短视频搜索seo
  • 成都高新区网站建设优化大师下载旧版本安装
  • 做效果图去哪个网站接活qq群排名优化
  • 上海网站建设做物流一百度推广怎么操作
  • 计算机网络技专业术网站开发网络营销中的seo是指
  • 清理网站后台缓存百度云盘
  • seo优化知识关键词优化百家号
  • 电商网站建设多少钱武汉建站公司
  • 手机网站和电脑网站的区别汽车宣传软文
  • 中山市建设局投诉网站seo公司重庆
  • dw做网站怎么加视频网站的推广方法有哪些
  • 机器设备行业网站模板软文广告经典案例100字
  • 网站建设是不是可以免费建站百度宣传做网站多少钱
  • 潍坊中小企业网站制作哪个app可以找培训班
  • 个人网站经营性备案百度推广怎么添加关键词
  • 园区网站建设目的baidu百度
  • wordpress站群+优化惠州网络营销