0

Is there any way to run SqlCommand.ExecuteScalar() asynchronously and then cancel it (on the server side as well) whilst it's being executed?

Bridge
  • 29,818
  • 9
  • 60
  • 82
Eugene
  • 1,515
  • 1
  • 13
  • 23

1 Answers1

4

.NET Framework 4.5 has a ExecuteScalarAsync() method.
See here: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executescalarasync(v=vs.110).aspx

ExecuteScalarAsync() also has an overload with a CancellationToken parameter that can be used to abandon the operation before the command timeout elapses.

Mark
  • 1,455
  • 3
  • 28
  • 51