ClearScript Library
ClearScript Library
ClearScript Library Reference
Microsoft.ClearScript.JavaScript
JavaScriptExtensions Class
JavaScriptExtensions Methods
ToPromise Method
ToPromise(Task) Method
ToPromise<T>(Task<T>) Method
ToPromise(ValueTask) Method
ToPromise<T>(ValueTask<T>) Method
ToPromise(Task, ScriptEngine) Method
ToPromise<T>(Task<T>, ScriptEngine) Method
ToPromise(ValueTask, ScriptEngine) Method
ToPromise<T>(ValueTask<T>, ScriptEngine) Method

# JavaScriptExtensionsToPromise T(Task T, ScriptEngine) Method

Converts a TaskTResult instance to a promise for use with script code running in the specified script engine.
Namespace: Microsoft.ClearScript.JavaScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.5.0
Syntax
C#
VB
C++
F#
Copy

    public static Object ToPromise<T>(
    	this Task<T> task,
    	ScriptEngine engine
    )

    <ExtensionAttribute>
    Public Shared Function ToPromise(Of T) (
    	task As Task(Of T),
    	engine As ScriptEngine
    ) As Object

    public:
    [ExtensionAttribute]
    generic<typename T>
    static Object^ ToPromise(
    	Task<T>^ task,
    	ScriptEngine^ engine
    )

    [<ExtensionAttribute>]
    static member ToPromise :
            task : Task<'T> *
            engine : ScriptEngine -> Object

#### Parameters

task Task T
  The task to convert to a promise.
engine ScriptEngine
  The script engine in which the promise will be used.

#### Type Parameters

T
  The task's result type.

#### Return Value

Object
A promise that represents the task's asynchronous operation.

#### Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Task T. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also

#### Reference

JavaScriptExtensions Class
ToPromise Overload
Microsoft.ClearScript.JavaScript Namespace

Copyright © Microsoft Corporation. All rights reserved.

Send comments on this topic to Microsoft