Show / Hide Table of Contents

# Class AsyncContextThread

Provides a simplified interface for creating a new thread and establishing an AsyncContext in it.

##### Inheritance

System.Object
AsyncContextThread

##### 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 class AsyncContextThread

### Constructors

| Improve this Doc View Source

#### AsyncContextThread(String)

Initializes a new instance of the AsyncContextThread class.

##### Declaration

    public AsyncContextThread(string threadName)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | threadName | The name of the thread for debugging purposes.

### Methods

| Improve this Doc View Source

#### Run(Func<Task>)

Runs a task on the AsyncContextThread.

##### Declaration

    public Task Run(Func<Task> taskReturningFunc)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Func<System.Threading.Tasks.Task> | taskReturningFunc | A Func which returns the task to be run on the thread.

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task | A Task which can be used to monitor the thread for completion.

| Improve this Doc View Source

#### Stop()

Stops the thread task.

##### Declaration

    public void Stop()