mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Switch back to Tasks in binding queue (#510)
This commit is contained in:
@@ -288,7 +288,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
CancellationTokenSource cancelToken = new CancellationTokenSource();
|
CancellationTokenSource cancelToken = new CancellationTokenSource();
|
||||||
|
|
||||||
// run the operation in a separate thread
|
// run the operation in a separate thread
|
||||||
var bindThread = new Thread(() =>
|
var bindTask = Task.Run(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -304,11 +304,10 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
result = queueItem.ErrorHandler(ex);
|
result = queueItem.ErrorHandler(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, BindingQueue<T>.QueueThreadStackSize);
|
});
|
||||||
bindThread.Start();
|
|
||||||
|
|
||||||
// check if the binding tasks completed within the binding timeout
|
// check if the binding tasks completed within the binding timeout
|
||||||
if (bindThread.Join(bindTimeout))
|
if (bindTask.Wait(bindTimeout))
|
||||||
{
|
{
|
||||||
queueItem.Result = result;
|
queueItem.Result = result;
|
||||||
}
|
}
|
||||||
@@ -324,12 +323,9 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
|
|
||||||
lockTaken = false;
|
lockTaken = false;
|
||||||
|
|
||||||
Task.Run(() =>
|
bindTask
|
||||||
{
|
.ContinueWith((a) => bindingContext.BindingLock.Set())
|
||||||
// wait for the operation to complete before releasing the lock
|
.ContinueWithOnFaulted(t => Logger.Write(LogLevel.Error, "Binding queue threw exception " + t.Exception.ToString()));
|
||||||
bindThread.Join();
|
|
||||||
bindingContext.BindingLock.Set();
|
|
||||||
}).ContinueWithOnFaulted(t => Logger.Write(LogLevel.Error, "Binding queue threw exception " + t.Exception.ToString()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user