Delegate EvaluateAsyncDelegate
Represents a method that evaluates the specified C# code asynchronously and returns the result.
public delegate Task<object> EvaluateAsyncDelegate(object? owner, string code, object? options = null, object? globalObject = null, Type? globalType = null, CancellationToken cancellationToken = default)
Parameters
ownerobjectAn optional object that can be passed to the evaluation method in order to determine the context of the evaluation. For example Calculator passes itself.
codestringThe C# code to evaluate. This cannot be null or empty.
optionsobjectOptional script options to configure the evaluation, such as references and imports. Can be null.
globalObjectobjectAn optional object to provide global variables or state to the script. Can be null.
globalTypeTypeThe type of the global object, if specified. Can be null.
cancellationTokenCancellationTokenA token to monitor for cancellation requests. Defaults to None.
Returns
- Task<object>
A task that represents the asynchronous operation. The task result contains the evaluated value.
Remarks
This method uses the Roslyn scripting API to evaluate the provided C# code. The evaluation is performed in an isolated scripting context.