Show / Hide Table of Contents

Class ActionUtils

Inheritance
System.Object
ActionUtils
Namespace: Eco.Core.Utils.Threading
Assembly: Eco.Core.dll
Syntax
public static class ActionUtils : Object

Methods

AsAsyncAction(Action)

Represents System.Action as async action with immediate execution (invokes the action and returns System.Threading.Tasks.Task.CompletedTask).

Declaration
public static Func<Task> AsAsyncAction(Action action)
Parameters
Type Name Description
System.Action action
Returns
Type Description
System.Func<System.Threading.Tasks.Task>

AsAsyncCancellableAction(Action)

Represents System.Action as async cancellable action with immediate execution (invokes the action and returns System.Threading.Tasks.Task.CompletedTask).

Declaration
public static Func<CancellationToken, Task> AsAsyncCancellableAction(Action action)
Parameters
Type Name Description
System.Action action
Returns
Type Description
System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task>

SubscribeAndCall(Action, Action)

Declaration
public static void SubscribeAndCall(this Action a, Action callback)
Parameters
Type Name Description
System.Action a
System.Action callback

SubscribeAndCall<T1>(Action<T1>, Action)

Declaration
public static void SubscribeAndCall<T1>(this Action<T1> a, Action callback)
Parameters
Type Name Description
System.Action<T1> a
System.Action callback
Type Parameters
Name Description
T1

SubscribeAndCall<T1, T2>(Action<T1, T2>, Action)

Declaration
public static void SubscribeAndCall<T1, T2>(this Action<T1, T2> a, Action callback)
Parameters
Type Name Description
System.Action<T1, T2> a
System.Action callback
Type Parameters
Name Description
T1
T2

TryInvoke<T>(Action<T>, T, out Exception)

Try to invoke action. Return true if it succeeds and false if it fails with an exception.

Declaration
public static bool TryInvoke<T>(this Action<T> action, T parameter, out Exception exception)
Parameters
Type Name Description
System.Action<T> action
T parameter
System.Exception exception

Exception thrown by action. Null if no exception is thrown.

Returns
Type Description
System.Boolean
Type Parameters
Name Description
T

TryInvoke<T1, T2>(Action<T1, T2>, T1, T2, out Exception)

Try to invoke action. Return true if it succeeds and false if it fails with an exception.

Declaration
public static bool TryInvoke<T1, T2>(this Action<T1, T2> action, T1 parameter1, T2 parameter2, out Exception exception)
Parameters
Type Name Description
System.Action<T1, T2> action
T1 parameter1
T2 parameter2
System.Exception exception

Exception thrown by action. Null if no exception is thrown.

Returns
Type Description
System.Boolean
Type Parameters
Name Description
T1
T2

TryInvokeAll<T>(IEnumerable<Action<T>>, T, out List<Exception>)

Try to invoke actions passing parameter to each of them. Return true if they all succeed and false if any of them fails with an exception.

Declaration
public static bool TryInvokeAll<T>(this IEnumerable<Action<T>> actions, T parameter, out List<Exception> exceptions)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Action<T>> actions
T parameter
System.Collections.Generic.List<System.Exception> exceptions

Exceptions thrown by actions. Null if none were thrown.

Returns
Type Description
System.Boolean
Type Parameters
Name Description
T

TryInvokeAll<TDelegate, TParam>(IEnumerable<TDelegate>, TParam, Action<TDelegate, TParam>, out List<Exception>)

Try to invoke actions by passing them along with parameter to invoke function. Return true if they all succeed and false if any of them fails with an exception.

Declaration
public static bool TryInvokeAll<TDelegate, TParam>(this IEnumerable<TDelegate> actions, TParam parameter, Action<TDelegate, TParam> invoke, out List<Exception> exceptions)
    where TDelegate : Delegate
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TDelegate> actions
TParam parameter
System.Action<TDelegate, TParam> invoke

Function that will be called to invoke each action.

System.Collections.Generic.List<System.Exception> exceptions

Exceptions thrown by actions. Null if none were thrown.

Returns
Type Description
System.Boolean
Type Parameters
Name Description
TDelegate
TParam
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾