i'm using c# in net 2.0. winxp-sp2 machine.
I have a form, say FormGrid in that i have to do some work... there is a problem, related to datagridview and the datatable in the DataSource, and this problem require to work with the datatable in the same thread the dataridview is.
So, i make another thread with another form, say FormWatch to see the progress in formGrid. something like this:
In FormGrid i have something like:
Expand|Select|Wrap|Line Numbers
- void Process()
- {
- Thread t = new Thread(new ThreadStart(Watcher));
- t.Start();
- // works begin here
- }
- void Watcher()
- {
- using(FormWatch frm = new FormWatch())
- {
- frm.ShowDialog();
- }
- }
Things are almost fine... the problem is that when FormWatcher ends, the application lost focus completely, i have to clic it in the taskbar...
A workaround is to call the Activate method, something like:
Expand|Select|Wrap|Line Numbers
- delegate void DelegateActivate()
- void ProcActivate()
- {
- this.Activate();
- }
- void Watcher()
- {
- using(FormWatch frm = new FormWatch())
- {
- frm.ShowDialog();
- }
- this.BeingInvoke(new DelegateActivate(ProcActivate));
- }
This brings the application, but the flick is horrible...
¿Does anybody knows how to say FormWatch activate directly FormGrid? Or keep focus in the application?
Thanks