SqlCommand.ExecuteScalar Cancel

前端 未结 1 316
独厮守ぢ
独厮守ぢ 2021-01-28 06:23

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

相关标签:
1条回答
  • 2021-01-28 06:38

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

    0 讨论(0)
提交回复
热议问题