I have some long processes in my app, so I've created a WAIT PLEASE form and I call on another thread like this:
public void ShowWait()
{
continueWait = true;
ThreadPool.QueueUserWorkItem((x) =>
{
using (frmWait espera = new frmWait())
{
espera.ShowInTaskbar = false;
espera.Show();
while (continueWait)
Application.DoEvents();
espera.Close();
}
});
}
And to close the form I use:
public void HideWait()
{
continueWait = false;
}
It works fine, but I have a problem, when the wait form is shown, the main form losses the focus and any other application running (Excel, Word, etc) at the same time goes to the top and my app goes to the back of all applications. I tried to use Activate() and Focus() but only the frame on the taskbar activates, but the app remains on the back of all applications.
Any light on this?
Thanks in advance