Eugene
Eugene

Reputation: 1535

SqlCommand.ExecuteScalar Cancel

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

Upvotes: 0

Views: 925

Answers (1)

Mark
Mark

Reputation: 1537

.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.

Upvotes: 4

Related Questions