Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Runs the specified asynchronous method.
Namespace: Microsoft.VisualStudio.Threading
Assembly: Microsoft.VisualStudio.Threading (in Microsoft.VisualStudio.Threading.dll)
Syntax
'Declaration
Public Sub Run ( _
asyncMethod As Func(Of Task) _
)
public void Run(
Func<Task> asyncMethod
)
public:
void Run(
Func<Task^>^ asyncMethod
)
member Run :
asyncMethod:Func<Task> -> unit
public function Run(
asyncMethod : Func<Task>
)
Parameters
asyncMethod
Type: System.Func<Task>The asynchronous method to execute.
Examples
On the threadpool or Main thread, this method blocks the calling thread until all async operations in the delegate complete.
ThreadHelper.JoinableTaskFactory.Run(async delegate {
// still on the threadpool or Main thread as before.
await OperationAsync();
// still on the threadpool or Main thread as before.
await Task.Run(async delegate {
// Now we're on a threadpool thread.
await Task.Yield();
// still on a threadpool thread.
});
// Now back on the Main thread (or threadpool thread if that's where we started).
});
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.