mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Only register message handler once for GO N queries (#611)
This commit is contained in:
committed by
Karl Burtram
parent
7415c529f3
commit
b81ba929ba
@@ -242,6 +242,14 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
{
|
{
|
||||||
await BatchStart(this);
|
await BatchStart(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register the message listener to *this instance* of the batch
|
||||||
|
// Note: This is being done to associate messages with batches
|
||||||
|
ReliableSqlConnection sqlConn = conn as ReliableSqlConnection;
|
||||||
|
if (sqlConn != null)
|
||||||
|
{
|
||||||
|
sqlConn.GetUnderlyingConnection().InfoMessage += ServerMessageHandler;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -262,7 +270,6 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// Remove the message event handler from the connection
|
// Remove the message event handler from the connection
|
||||||
ReliableSqlConnection sqlConn = conn as ReliableSqlConnection;
|
|
||||||
if (sqlConn != null)
|
if (sqlConn != null)
|
||||||
{
|
{
|
||||||
sqlConn.GetUnderlyingConnection().InfoMessage -= ServerMessageHandler;
|
sqlConn.GetUnderlyingConnection().InfoMessage -= ServerMessageHandler;
|
||||||
@@ -438,9 +445,6 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
DbCommand dbCommand;
|
DbCommand dbCommand;
|
||||||
if (sqlConn != null)
|
if (sqlConn != null)
|
||||||
{
|
{
|
||||||
// Register the message listener to *this instance* of the batch
|
|
||||||
// Note: This is being done to associate messages with batches
|
|
||||||
sqlConn.GetUnderlyingConnection().InfoMessage += ServerMessageHandler;
|
|
||||||
dbCommand = sqlConn.GetUnderlyingConnection().CreateCommand();
|
dbCommand = sqlConn.GetUnderlyingConnection().CreateCommand();
|
||||||
|
|
||||||
// Add a handler for when the command completes
|
// Add a handler for when the command completes
|
||||||
|
|||||||
Reference in New Issue
Block a user