Ejemplo n.º 1
0
		public static IAsyncResult GetAsyncResult (Task task, AsyncCallback callback, object state)
		{
			if (task == null)
				return null;

			var result = new TaskAsyncResult (task, callback, state);

			if (callback != null) {
				if (result.CompletedSynchronously)
					callback (result);
				else
					task.ContinueWith (invokeCallback, result);
			}

			return result;
		}
Ejemplo n.º 2
0
        public static IAsyncResult GetAsyncResult(Task task, AsyncCallback callback, object state)
        {
            if (task == null)
            {
                return(null);
            }

            var result = new TaskAsyncResult(task, callback, state);

            if (callback != null)
            {
                if (result.CompletedSynchronously)
                {
                    callback(result);
                }
                else
                {
                    task.ContinueWith(invokeCallback, result);
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
 void IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
 {
     TaskAsyncResult.Wait(result);
 }
        IAsyncResult GetAsyncResult(object sender, EventArgs e, AsyncCallback callback, object state)
        {
            Task task = taskEventHandler(sender, e);

            return(TaskAsyncResult.GetAsyncResult(task, callback, state));
        }
Ejemplo n.º 5
0
        IAsyncResult IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            Task task = ProcessRequestAsync(context);

            return(TaskAsyncResult.GetAsyncResult(task, cb, extraData));
        }