一款简单易用的基础网络通讯组件库。

AsyncAutoResetEvent 类

表示一个异步自动重置事件,提供基于Task的异步等待机制。

Definition

命名空间: TouchSocket.Core
程序集: TouchSocket.Core (在 TouchSocket.Core.dll 中) 版本:4.0.0-beta.143+5fcca7a4e70968794985dc3793adc50531308be6
C#
public class AsyncAutoResetEvent
Inheritance
Object    AsyncAutoResetEvent

备注

AsyncAutoResetEvent是AutoResetEvent的异步版本实现, 允许多个任务异步等待信号,当信号被设置时,只有一个等待者会被唤醒,然后信号自动重置。 此实现基于微软VS相关库的代码。

与传统的AutoResetEvent不同,此类不会阻塞线程,而是返回可等待的Task, 更适合在异步编程模式中使用,能够避免线程阻塞并提高系统的并发性能。 此代码摘抄自微软VS相关库。

构造函数

AsyncAutoResetEvent 初始化AsyncAutoResetEvent类的新实例,默认不允许内联等待者。
AsyncAutoResetEvent(Boolean) 初始化AsyncAutoResetEvent类的新实例。

方法

EqualsDetermines whether the specified object is equal to the current object.
(继承自 Object。)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(继承自 Object。)
GetHashCodeServes as the default hash function.
(继承自 Object。)
GetTypeGets the Type of the current instance.
(继承自 Object。)
MemberwiseCloneCreates a shallow copy of the current Object.
(继承自 Object。)
Set 解除阻塞一个等待者,或者如果没有等待者则设置信号,使下一个等待者可以立即继续执行。
SetAll 解除阻塞所有当前等待的等待者。
ToStringReturns a string that represents the current object.
(继承自 Object。)
WaitOneAsync 返回一个可等待对象,用于异步获取下一个信号。
WaitOneAsync(CancellationToken) 返回一个可等待对象,用于异步获取下一个信号,并支持取消操作。
WaitOneAsync(TimeSpan) 返回一个可等待对象,用于异步获取下一个信号,并支持超时。

扩展方法

Map 将源对象的属性映射到目标对象的属性中。
(由 Mapper 定义。)
Map 将源对象映射到目标类型的实例。
(由 Mapper 定义。)
MapTTarget 将源对象映射到指定目标类型的新实例。
(由 Mapper 定义。)
ToJsonString 转换为Json
(由 SerializeConvert 定义。)

参见