Hi Shabbir,

I am still not able to have the focus on Cancelbutton so that i can click during an asynchronous process takes place.This is the code sample.

I am calling Test() method which will take some time to finish.During that time I wanna click on the cancel button which i am not able to do.
Code:
public delegate void AsyncFactorCaller();
AsyncFactorCaller factorDelegate;

 public void Test()
        {

            for (int i = 0; i <= 1000000000; i++)
            {

            }

           
        }
        public void CallBackTest(IAsyncResult result)
        {
            DisplayInfoDelegate del = new DisplayInfoDelegate(Tick1);
            AsyncFactorCaller factorDelegate = (AsyncFactorCaller)result.AsyncState;
            factorDelegate.EndInvoke(result);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            btnCancel.Visible = true;
            btnCancel.Focus();
            btnCancel.Refresh();

            factorDelegate = new AsyncFactorCaller(Test);
            IAsyncResult result = factorDelegate.BeginInvoke(new AsyncCallback(CallBackTest), null);
            while (!result.IsCompleted)
            {
            }
        }

Last edited by shabbir; 22Nov2006 at 14:47.. Reason: Code formating.