From d8176f977eea90fa65206e2af5ae570f5f4f1c1e Mon Sep 17 00:00:00 2001 From: dyarkovoy Date: Thu, 15 Jun 2017 14:00:43 +0300 Subject: [PATCH] Update command.cs Currently if MySqlCommand was asynchronously executed with a CancellationToken, and that token is cancelled After the command is disposed, the MySqlCommand throws NullReferenceException because at that point command's connection is null. This is OK for release builds because the exception would be caught by System.Data.Common.DbCommand's internal logic, but it is very annoying to see these exceptions when debugging. Additionally, it ads extra unnecessary overhead of throwing/catching an exception. The fix is simply to check whether connection is null before calling CancelQuery. --- Source/MySql.Data/command.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/MySql.Data/command.cs b/Source/MySql.Data/command.cs index f92babef..7e84f069 100644 --- a/Source/MySql.Data/command.cs +++ b/Source/MySql.Data/command.cs @@ -1,4 +1,4 @@ -// Copyright