Is there any way to run SqlCommand.ExecuteScalar()
asynchronously and then cancel it (on the server side as well) whilst it\'s being executed?
.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.