public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            var apm = new ProcessResult(cb, context, extraData);

            context.Response.Write(string.Format("<h1>This handler uses a simple custom implementation of the IAsyncResult interface (Async Programming Model)</h1><br/><br/><hr/><br/><br/>"));

            context.Response.Write(string.Format("<br/>Before calling start asynchronously: {0} ThreadPool ID: {1}", DateTime.Now.ToString(), Thread.CurrentThread.ManagedThreadId));
            apm.Start();
            context.Response.Write(string.Format("<br/>After calling start asynchronously: {0} ThreadPool ID: {1}", DateTime.Now.ToString(), Thread.CurrentThread.ManagedThreadId));

            return apm;
        }
예제 #2
0
        public IAsyncResult BeginProcessRequest(object sender, EventArgs e, AsyncCallback cb, object extraData)
        {
            HttpContext.Current.Response.Write(string.Format("<br /> Thread ID: {0} From: {1}", Thread.CurrentThread.ManagedThreadId, MethodInfo.GetCurrentMethod().Name));
            //Func<TimeSpan, DateTime> operation = this.ExecuteLongTimeConsumingOperation;

            //return operation.BeginInvoke(TimeSpan.FromDays(10), cb, extraData);

            var f = new ProcessResult(cb, this.Context, extraData);

            f.Start();

            return f;
        }