Show / Hide Table of Contents

# Class AsyncContext

Simplifies the setup of a SynchronizationContext for the use of async calls in the current thread.

##### Inheritance

System.Object
AsyncContext

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace:Microsoft.SqlTools.ServiceLayer.Utility

###### Assembly:Microsoft.SqlTools.ServiceLayer.dll

##### Syntax

    public static class AsyncContext

### Methods

| Improve this Doc View Source

#### Start(Func<Task>)

Starts a new ThreadSynchronizationContext, attaches it to the thread, and then runs the given async main function.

##### Declaration

    public static void Start(Func<Task> asyncMainFunc)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Func<System.Threading.Tasks.Task> | asyncMainFunc | The Task-returning Func which represents the "main" function for the thread.