昨天阅读 corefx 中 System.Data.SqlClient 的源代码 SqlDataReader.cs 时发现用到了 TaskCompletionSource
TaskCompletionSource<bool> source = new TaskCompletionSource<bool>();
Task original = Interlocked.CompareExchange(ref _currentTask, source.Task, null);
if (original != null)
{
source.SetException(ADP.ExceptionWithStackTrace(SQL.PendingBeginXXXExists()));
return source.Task;
}请问 TaskCompletionSource 的用途是什么?在什么情况下会用到它?
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1775/viewspace-3151923/ ,如需转载,请注明出处,否则将追究法律责任。