Useful link
http://support.microsoft.com/kb/839201

On Mon, Sep 7, 2009 at 5:34 PM, Benj Nunez <[email protected]> wrote:

>
> Hello experts,
>
> I need your help. I have code which uses thread. I'm not sure if I'm
> doing this correctly (my comments
> inserted in the code below):
>
>
>            WaitForm waitForm = new WaitForm();
>             waitForm.Show();
>
>                thrdParam = new Thread(new ParameterizedThreadStart
> (runThreadedQuery));
>                thrdParam.Start(strQuery);
>
>                menuStrip.Enabled = false;
>                btnExecute.Enabled = false;
>                TabControl.Enabled = false;
>
>                while (thrdParam.IsAlive)
>                {
>                    waitForm.Refresh();
>                    /* Maintains that the Waitform's close box is
> disabled.
>                       But the MainForm still "remembers" the keys
> pressed.
>                       (e.g. alt+f4). So far, only ALT+F4 is trapped.
> I have code
>                       under MainForm_FormClosing() which has a prompt
> before closing. */
>                }
>
>                waitForm.Close();
>                dgvQueryResult.Focus();
>                menuStrip.Enabled = true;
>                btnExecute.Enabled = true;
>                TabControl.Enabled = true;
>
>
> While a thread is running, I intentionally keep pressing shortcut keys
> like ALT+H+B to show
> the "About" window (which will not appear yet because of the loop).
> When the thread ends, the "About" window appears because it has
> "remembered" my keystrokes.
>
> I want the main form to ignore whatever key was pressed. How do I
> suspend/resume key events.
> Is it possible? Am I doing this correctly? Please help.
>
>
>
> Benj
>
>

Reply via email to