加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 异步写入套接字线程安全吗?

发布时间:2020-12-15 06:57:53 所属栏目:百科 来源:网络整理
导读:考虑Socket.BeginSend()方法.如果两个线程池线程同时调用此方法,它们各自的消息是否相互混合,或者套接字类是否保持不发生? 解决方法 我发现一个熟悉的 post on the MSDN forum似乎回答了你的问题. You can queue multiple BeginSends at the same time. You
考虑Socket.BeginSend()方法.如果两个线程池线程同时调用此方法,它们各自的消息是否相互混合,或者套接字类是否保持不发生?

解决方法

我发现一个熟悉的 post on the MSDN forum似乎回答了你的问题.
  1. You can queue multiple BeginSends at the same time. You don’t need to lock

编辑:

更有趣的信息:

如果您在Remark section of the MSDN doc BeginSend()中向下滚动一下,您将发现有趣的使用可能与您相关的回调方法.

[…] If you want the original thread to block after you call the BeginSend method,use the WaitHandle.WaitOne method. […]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读