Show / Hide Table of Contents

# Class ServiceHost

SQL Tools VS Code Language Server request handler. Provides the entire JSON RPC implementation for sending/receiving JSON requests and dispatching the requests to handlers that are registered prior to startup.

##### Inheritance

System.Object
ProtocolEndpoint
ServiceHostBase
ServiceHost

##### Inherited Members

ServiceHostBase.OnStart()
ProtocolEndpoint.MessageDispatcher
ProtocolEndpoint.Start()
ProtocolEndpoint.WaitForExit()
ProtocolEndpoint.Stop()
ProtocolEndpoint.SendRequest<TParams, TResult>(RequestType<TParams, TResult>, TParams)
ProtocolEndpoint.SendRequest<TParams, TResult>(RequestType<TParams, TResult>, TParams, Boolean)
ProtocolEndpoint.SendEvent<TParams>(EventType<TParams>, TParams)
ProtocolEndpoint.SetRequestHandler<TParams, TResult>(RequestType<TParams, TResult>, Func<TParams, RequestContext<TResult>, Task>)
ProtocolEndpoint.SetEventHandler<TParams>(EventType<TParams>, Func<TParams, EventContext, Task>)
ProtocolEndpoint.SetEventHandler<TParams>(EventType<TParams>, Func<TParams, EventContext, Task>, Boolean)
ProtocolEndpoint.OnConnect()
ProtocolEndpoint.OnStop()
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.Hosting

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

##### Syntax

    public sealed class ServiceHost : ServiceHostBase, IProtocolEndpoint, IMessageSender

### Properties

| Improve this Doc View Source

#### Instance

Current instance of the ServiceHost

##### Declaration

    public static ServiceHost Instance { get; }

##### Property Value

Type | Description
--- | ---
ServiceHost |

### Methods

| Improve this Doc View Source

#### Initialize()

Provide initialization that must occur after the service host is started

##### Declaration

    public void Initialize()

| Improve this Doc View Source

#### RegisterInitializeTask(ServiceHost.InitializeCallback)

Add a new method to be called when the initialize request is submitted

##### Declaration

    public void RegisterInitializeTask(ServiceHost.InitializeCallback callback)

##### Parameters

Type | Name | Description
--- | --- | ---
ServiceHost.InitializeCallback | callback | Callback to perform when an initialize request is submitted

| Improve this Doc View Source

#### RegisterShutdownTask(ServiceHost.ShutdownCallback)

Adds a new callback to be called when the shutdown request is submitted

##### Declaration

    public void RegisterShutdownTask(ServiceHost.ShutdownCallback callback)

##### Parameters

Type | Name | Description
--- | --- | ---
ServiceHost.ShutdownCallback | callback | Callback to perform when a shutdown request is submitted