B
Ben Schwehn
Hello all,
I'm experiencing a samewhat strange behaviour when running my Windows
Forms app from withing Visual Studio 2008. The application is
multithreaded and the workerthread fires an event that should enable a
button in the GUI. I'm using BeginInvoke to call the method that enables
the button on the GUI thread. The code is very straight forward:
On the worker thread:
[...]
ffmpegProcess.WaitForExit();
if (GeneratorFinished != null)
{
GeneratorFinished(this, null); //event that triggers the button enabler
}
In the GUI Class:
void generator_GeneratorFinished(object sender, EventArgs e)
{
if (this.InvokeRequired)
{
MethodInvoker invoker = new MethodInvoker(EnableStartButton);
invoker.BeginInvoke(null, null);
}
else
{
EnableStartButton();
}
}
private void EnableStartButton()
{
btnStart.Enabled = true;
}
This works as expected when running the program outside of VS. However if
I start the Program within VS (by hitting F5) the Button does change its
appearance from disabled to enabled but does still not accept mouse
input. The button works when I press the accelerator key (Alt+S). I can
also tab to the button (it recieves focus) and press enter. However
tabbing to it and pressing space doesn't work. Once the button got
activated via tab+enter or the accelerator key it 'unsticks' and accepts
mouse input again.
It's not a big deal but a little annyoing and I'm curious if there's
anything I can do to prevent it from happening?
Thanks
Ben
I'm experiencing a samewhat strange behaviour when running my Windows
Forms app from withing Visual Studio 2008. The application is
multithreaded and the workerthread fires an event that should enable a
button in the GUI. I'm using BeginInvoke to call the method that enables
the button on the GUI thread. The code is very straight forward:
On the worker thread:
[...]
ffmpegProcess.WaitForExit();
if (GeneratorFinished != null)
{
GeneratorFinished(this, null); //event that triggers the button enabler
}
In the GUI Class:
void generator_GeneratorFinished(object sender, EventArgs e)
{
if (this.InvokeRequired)
{
MethodInvoker invoker = new MethodInvoker(EnableStartButton);
invoker.BeginInvoke(null, null);
}
else
{
EnableStartButton();
}
}
private void EnableStartButton()
{
btnStart.Enabled = true;
}
This works as expected when running the program outside of VS. However if
I start the Program within VS (by hitting F5) the Button does change its
appearance from disabled to enabled but does still not accept mouse
input. The button works when I press the accelerator key (Alt+S). I can
also tab to the button (it recieves focus) and press enter. However
tabbing to it and pressing space doesn't work. Once the button got
activated via tab+enter or the accelerator key it 'unsticks' and accepts
mouse input again.
It's not a big deal but a little annyoing and I'm curious if there's
anything I can do to prevent it from happening?
Thanks
Ben