There are some textboxes placed on a form along with one button.When the user presses the button a modal window pops up till the work is finished and that window shows that circling processing GIF image.
By showing the form as modal , the user will not be able to press the button again untill the shown modal window is closed, which happens automatically when the processing is done.
This I tried to achieve this effect by creating the button's click event as follows:
Futile attempt 1
{
OneForm oneform = new OneForm();
oneform.Show();// mod-less form
Thread.Sleep(); //Emulate work.Coz the Thread sleeps, the GIF icon can not animate
oneform.Close() ;
}
Futile attempt 2
{
OneForm oneform = new OneForm();
oneform.ShowDia log();// modal form
Thread.Sleep(); //Emulate work.GIF will animate but this line will never execute untill I close the modal form ! USELESS
}
Futile attempt 3
OneForm onefrm = new OneForm(); //oneform is a field so that I can access it from all methods
{
Thread th = new Thread(HeavyWor k);
th.Start();
oneform.ShowDia log();//main thread stops here untill I close it but I satrted another thread to execute my work, thank God
}
void HeavyWork()
{
Thread.Sleep(10 000);
onefrm.Close(); //OOps this is created in GUI thread so cant access/close it from any other thread
}
Futile attempt 4 //I used this coz it was doing my work, well...almost
{
Thread th = new Thread(SHowForm );
th.Start();
Thread.Sleep(10 000);
th.Abort(); //work done not close the form by ending the thread
}
void ShowForm()
{
new OneForm().ShowD ialog();
}
Now what happens is that the OneForm does not disappear untill I move the mouse on it.Even the dialog boxes are coming under it and when I move the mouse, it closes.
How to solve this ?
Thanks !
By showing the form as modal , the user will not be able to press the button again untill the shown modal window is closed, which happens automatically when the processing is done.
This I tried to achieve this effect by creating the button's click event as follows:
Futile attempt 1
{
OneForm oneform = new OneForm();
oneform.Show();// mod-less form
Thread.Sleep(); //Emulate work.Coz the Thread sleeps, the GIF icon can not animate
oneform.Close() ;
}
Futile attempt 2
{
OneForm oneform = new OneForm();
oneform.ShowDia log();// modal form
Thread.Sleep(); //Emulate work.GIF will animate but this line will never execute untill I close the modal form ! USELESS
}
Futile attempt 3
OneForm onefrm = new OneForm(); //oneform is a field so that I can access it from all methods
{
Thread th = new Thread(HeavyWor k);
th.Start();
oneform.ShowDia log();//main thread stops here untill I close it but I satrted another thread to execute my work, thank God
}
void HeavyWork()
{
Thread.Sleep(10 000);
onefrm.Close(); //OOps this is created in GUI thread so cant access/close it from any other thread
}
Futile attempt 4 //I used this coz it was doing my work, well...almost
{
Thread th = new Thread(SHowForm );
th.Start();
Thread.Sleep(10 000);
th.Abort(); //work done not close the form by ending the thread
}
void ShowForm()
{
new OneForm().ShowD ialog();
}
Now what happens is that the OneForm does not disappear untill I move the mouse on it.Even the dialog boxes are coming under it and when I move the mouse, it closes.
How to solve this ?
Thanks !
Comment