By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,163 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,163 IT Pros & Developers. It's quick & easy.

Calling api - bug, pr threading problem

P: n/a

Hi
I have a simple situation, and complicated for me problem.
I have an event that is raised if data receive to RS port.
This event calls few api functions
Here is the code:

case "Alt":
{
if (!isAltPressed)
{
keybd_event(18, 0, 0, UIntPtr.Zero);
isAltPressed = true;
notifyIcon1.ShowBalloonTip(1, "", "Alt is now
active", ToolTipIcon.Info);

System.Threading.Thread.Sleep(500);
break;
}

isAltPressed = false;
keybd_event(18, 0, 0x0002, UIntPtr.Zero);
notifyIcon1.ShowBalloonTip(1, "", "Alt is no more
active", ToolTipIcon.Info);

System.Threading.Thread.Sleep(500);
break;
}
case "Tab":
{
if (isAltPressed)
{
keybd_event(9, MapVirtualKey(9, 0), 0,
UIntPtr.Zero);
keybd_event(9, MapVirtualKey(9, 0), 0x0002,
UIntPtr.Zero);
}
break;
}
This code simulates pressing alt+tab.
And the problem is that in 1/5 of situations, when i try to deactivate ALT
key,alt+tab menu is still visible.
Algorithm is simple. Alt -> n-times TAB -> Alt again. Alt tab menu doesn't
wanish every time i do it this way.

I think that maybe it's threading problem or somthing of this kind.
For any help thanks.
May 21 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.