Table of Contents

TryInvoke Method

Definition

Namespace
Cuemon
Assemblies
Cuemon.Kernel.dll
Source
src/Cuemon.Kernel/Patterns.cs

TryInvoke(Action)

Returns a value that indicates whether the specified method can be invoked without an exception.

public static bool TryInvoke(Action method)

Parameters

method Action

The delegate that to invoke.

Returns

bool

true if method was called without raising an exception; otherwise false.

Remarks

Actually an anti-pattern in regards to swallowing exception. That said, there are situations where this is a perfectly valid approach.

TryInvoke<TResult>(Func<TResult>, out TResult)

Returns a value that indicates whether the specified method can be invoked without an exception.

public static bool TryInvoke<TResult>(Func<TResult> method, out TResult result)

Parameters

method Func<TResult>

The function delegate that will resolve result.

result TResult

When this method returns, contains the value returned from method; otherwise the default value for the type of the result parameter if an exception is thrown.

Returns

bool

true if an instance of TResult has been created; otherwise false.

Type Parameters

TResult

The type of the return value of the method.

Remarks