Skip to content

Class TaskAsyncHelper

Namespace: Tool.Utils.TaskHelper
Assembly: Tool.Net.dll

实现异步Task对象的异步实现类

csharp
public static class TaskAsyncHelper

Inheritance

objectTaskAsyncHelper

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Remarks

代码由逆血提供支持

Methods

BeginTask(Func<Task>, AsyncCallback, object)

将一个异步任务对象转换成IAsyncResult对象

csharp
public static IAsyncResult BeginTask(Func<Task> taskFunc, AsyncCallback callback, object state)

Parameters

taskFunc Func<Task>

一个异步对象

callback AsyncCallback

异步完成时使用的回调对象

state object

附带的数据

Returns

IAsyncResult

返回

EndTask(IAsyncResult)

用于结束异步完成任务

csharp
public static void EndTask(IAsyncResult ar)

Parameters

ar IAsyncResult

开始任务时的对象

ExecuteWithTimeoutAsync(Func<Task>, TimeSpan, Action)

执行任务,超时时回调委托

csharp
public static Task ExecuteWithTimeoutAsync(Func<Task> task, TimeSpan timeout, Action timeoutCallback)

Parameters

task Func<Task>

任务

timeout TimeSpan

超时时间

timeoutCallback Action

回调委托

Returns

Task

任务结果

基于Apache-2.0协议开源