0

I have the following problem: my .NET app has started a long DB query (a call of SQL proc) using DBCommand.ExecuteScalar(). Then another thread of the app tried to cancel (abort) the query by calling DbCommand.Cancel() method. But nothing has happened. I am thinking – maybe this was because of the DbCommand object had a large (many hours) value in DbCommand.CommandTimeout ? Maybe the logic of DbCommand.Cancel() is the following: “first wait the time DbCommand.CommandTimeout, and only then really abort the command that is being executing” - ? Sounds weird; but I have no other explanations. The documentation about the method (https://learn.microsoft.com/en-us/dotnet/api/system.data.common.dbcommand.cancel?view=netframework-4.7.2 ) tells nothing about this.

Victor Sotnikov
  • 177
  • 1
  • 2
  • 15
  • https://stackoverflow.com/questions/10244392/sqlcommand-executescalar-cancel – farbiondriven Jun 26 '20 at 12:55
  • Does this answer your question? [SqlCommand.ExecuteScalar Cancel](https://stackoverflow.com/questions/10244392/sqlcommand-executescalar-cancel) – Pavel Anikhouski Jun 26 '20 at 12:59
  • Thank you for the response. But let's suppose that I want to preserve the code that uses the synchronous DBCommand.ExecuteScalar(). So, then I have the same question - why my DbCommand.Cancel() did not work? – Victor Sotnikov Jun 26 '20 at 13:48

0 Answers0