示例#1
0
        protected AsyncStep CallTask(Func <TIteratorAsyncResult, TimeSpan, Task> taskFunc, ExceptionPolicy policy)
        {
            return(this.CallAsync(
                       (thisPtr, t, c, s) =>
            {
                var task = taskFunc(thisPtr, t);
                if (task.Status == TaskStatus.Created)
                {
                    // User func might have created a Task without starting.
                    // This can potentially hang threads.
                    task.Start();
                }

                return task.ToAsyncResult(c, s);
            },
                       (thisPtr, r) => TaskHelpers.EndAsyncResult(r),
                       policy));
        }
示例#2
0
 public static void EndWrite(this Stream stream, IAsyncResult asyncResult)
 {
     TaskHelpers.EndAsyncResult(asyncResult);
 }
示例#3
0
 public static void EndAuthenticateAsServer(this SslStream sslStream, IAsyncResult asyncResult)
 {
     TaskHelpers.EndAsyncResult(asyncResult);
 }
示例#4
0
 public static int EndRead(this Stream stream, IAsyncResult asyncResult)
 {
     return(TaskHelpers.EndAsyncResult <int>(asyncResult));
 }