Example #1
0
        public IAsyncResult BeginProcessRequest(object sender, EventArgs eventArgs, AsyncCallback cb, object extraData)
        {
            Session["AsyncIsCompleted"] = null;
            Label1.Text = "BeginGetAsyncData: thread #" + Thread.CurrentThread.ManagedThreadId;
            Trace.Write("BeginGetAsyncData", Label2.Text); 
            //Response.Write("<p>BeginProcessRequest starting ...</p>");
            
            AsyncOperation = new AsyncOperationPattern(CallBackResult, this.Context, extraData);
            AsyncOperation.StartAsync();
            _Observer = new Observer<AsyncOperationPattern, AsyncViewer>(AsyncOperation, this);

            Session["label3"] = Label3;
            

            Label2.Text = "BeginProcessRequest queued ...";
            //Response.Write("<p>BeginProcessRequest queued ...</p>");
            return m_MyRequest.BeginGetResponse(cb, Session["label3"]); 
        }
Example #2
0
        protected void Timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                Label3.Text = Session["label3"] as string;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            if (AsyncOperation != null && AsyncOperation.IsCompleted)
            {
                Timer1.Enabled = false;
                Button1.Enabled = true;
                AsyncOperation = null;
            }
        }
Example #3
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     try
     {
         _Halted = true;
         AsyncOperation = null;
         Button1.Enabled = true;
         //if (operationPattern != null) operationPattern.Stop();
     }
     catch (Exception ex)
     {
         ;
     }
     Timer1.Enabled = false;
     Button1.Enabled = true;
 }