gpt4 book ai didi

.net - System.Net.WebSockets.ClientWebSocket 的线程安全

转载 作者:行者123 更新时间:2023-12-04 13:04:27 26 4
gpt4 key购买 nike

document不清楚System.Net.WebSockets.ClientWebSocket的线程安全性类(class)。

拨打 SendAsync 安全吗?多个线程同时调用的方法?

最佳答案

它是线程安全的,足以完成一些工作。

根据source (感谢 Michael Kropat 在 https://www.codetinkerer.com/2018/06/05/aspnet-core-websockets.html 讨论它)

Thread-safety:

  • It’s acceptable to call ReceiveAsync and SendAsync in parallel. One of each may run concurrently.
  • It’s acceptable to have a pending ReceiveAsync while CloseOutputAsync or CloseAsync is called.
  • Attempting to invoke any other operations in parallel may corrupt the instance. Attempting to invoke a send operation while another is in progress or a receive operation while another is in progress will result in an exception.

关于.net - System.Net.WebSockets.ClientWebSocket 的线程安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38582398/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com