Skip to content

Class WaitAction<T, TResult>

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

创建任务执行对象

csharp
public class WaitAction<T, TResult> : IDisposable

Type Parameters

T

TResult

Inheritance

objectWaitAction<T, TResult>

Implements

IDisposable

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

代码由逆血提供支持

Constructors

WaitAction(Func<T, ValueTask<TResult>>, T)

创建有返回结果的任务

csharp
public WaitAction(Func<T, ValueTask<TResult>> func, T state)

Parameters

func Func<T, ValueTask<TResult>>

任务

state T

参数

WaitAction(Action<T>, T)

创建无返回结果的任务

csharp
public WaitAction(Action<T> action, T state)

Parameters

action Action<T>

任务

state T

参数

Properties

Exception

任务执行中发生的异常

csharp
public Exception Exception { get; }

Property Value

Exception

IsCompleted

任务完成情况

csharp
public bool IsCompleted { get; }

Property Value

bool

IsException

是否发生异常

csharp
public bool IsException { get; }

Property Value

bool

IsWait

是否正在调用Wait函数

csharp
public bool IsWait { get; }

Property Value

bool

Result

任务完成后的结果

csharp
public TResult Result { get; }

Property Value

TResult

State

需要的参数

csharp
public T State { get; }

Property Value

T

WaitTimeout

Wait函数最大等待时长 -1 无限制等待

csharp
public int WaitTimeout { get; set; }

Property Value

int

Methods

Dispose()

回收对象

csharp
public void Dispose()

Run()

启动已就绪的任务

csharp
public ValueTask Run()

Returns

ValueTask

Wait()

其他线程中可用等待获取的任务结果

csharp
public bool Wait()

Returns

bool

返回成功失败

基于Apache-2.0协议开源