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

SystemThreadingExtension 类

SystemThreadingExtension

Definition

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

方法

ApplyChangeOptimisticallyT(T, FuncT, T) Optimistically performs some value transformation based on some field and tries to apply it back to the field, retrying as many times as necessary until no other thread is manipulating the same field.
ApplyChangeOptimisticallyT, TArg(T, TArg, FuncT, TArg, T) Optimistically performs some value transformation based on some field and tries to apply it back to the field, retrying as many times as necessary until no other thread is manipulating the same field.
AttachCancellationT 如果给定的 CancellationToken 被取消,则取消 Task
ConfigureFalseAwait(Task) 配置ConfigureAwait为
ConfigureFalseAwaitT(TaskT) 配置ConfigureAwait为
CreateReadLock 创建一个可释放的读取锁
CreateWriteLock 创建一个可释放的写入锁
FireAndForget 启动一个任务并立即返回,任务执行过程中发生的异常不会导致程序崩溃。
GetFalseAwaitResult(Task) 同步配置ConfigureAwait为时的执行。
GetFalseAwaitResultT(TaskT) 同步获取配置ConfigureAwait为时的结果。
GetTokenOrCanceled 获取 CancellationToken,如果 tokenSource 为 null,则返回一个已取消的 CancellationToken
SafeCancel 安全地取消 CancellationTokenSource,并返回操作结果。
WaitResultAsync 异步等待信号量并返回结果,支持取消令牌。
WaitTime 使用指定的超时和取消令牌等待信号量。
WaitTimeAsync 异步等待信号量,具有指定的超时和取消令牌。
WithCancellation(Task, CancellationToken) Wraps a task with one that will complete as cancelled based on a cancellation cancellationToken, allowing someone to await a task but be able to break out early by cancelling the cancellationToken.
WithCancellationT(TaskT, CancellationToken) Wraps a task with one that will complete as cancelled based on a cancellation cancellationToken, allowing someone to await a task but be able to break out early by cancelling the cancellationToken.

参见