mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
handling database info and metadata request async (#541)
This commit is contained in:
@@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
|||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Microsoft.SqlServer.Management.Smo;
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||||
{
|
{
|
||||||
@@ -143,6 +144,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
RequestContext<GetDatabaseInfoResponse> requestContext)
|
RequestContext<GetDatabaseInfoResponse> requestContext)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
Func<Task> requestHandler = async () =>
|
||||||
{
|
{
|
||||||
ConnectionInfo connInfo;
|
ConnectionInfo connInfo;
|
||||||
AdminService.ConnectionServiceInstance.TryFindConnection(
|
AdminService.ConnectionServiceInstance.TryFindConnection(
|
||||||
@@ -155,9 +158,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
|||||||
info = GetDatabaseInfo(connInfo);
|
info = GetDatabaseInfo(connInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
await requestContext.SendResult(new GetDatabaseInfoResponse(){
|
await requestContext.SendResult(new GetDatabaseInfoResponse()
|
||||||
|
{
|
||||||
DatabaseInfo = info
|
DatabaseInfo = info
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Task task = Task.Run(async () => await requestHandler()).ContinueWithOnFaulted(async t =>
|
||||||
|
{
|
||||||
|
await requestContext.SendError(t.Exception.ToString());
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using Microsoft.SqlTools.Hosting.Protocol;
|
|||||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts;
|
using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.Metadata
|
namespace Microsoft.SqlTools.ServiceLayer.Metadata
|
||||||
{
|
{
|
||||||
@@ -65,6 +66,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Metadata
|
|||||||
RequestContext<MetadataQueryResult> requestContext)
|
RequestContext<MetadataQueryResult> requestContext)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
Func<Task> requestHandler = async () =>
|
||||||
{
|
{
|
||||||
ConnectionInfo connInfo;
|
ConnectionInfo connInfo;
|
||||||
MetadataService.ConnectionServiceInstance.TryFindConnection(
|
MetadataService.ConnectionServiceInstance.TryFindConnection(
|
||||||
@@ -84,6 +87,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Metadata
|
|||||||
{
|
{
|
||||||
Metadata = metadata.ToArray()
|
Metadata = metadata.ToArray()
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Task task = Task.Run(async () => await requestHandler()).ContinueWithOnFaulted(async t =>
|
||||||
|
{
|
||||||
|
await requestContext.SendError(t.Exception.ToString());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user