473,545 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling api - bug, pr threading problem


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.Sho wBalloonTip(1, "", "Alt is now
active", ToolTipIcon.Inf o);

System.Threadin g.Thread.Sleep( 500);
break;
}

isAltPressed = false;
keybd_event(18, 0, 0x0002, UIntPtr.Zero);
notifyIcon1.Sho wBalloonTip(1, "", "Alt is no more
active", ToolTipIcon.Inf o);

System.Threadin g.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
0 1039

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2407
by: Matthew Bell | last post by:
Hi, I've got a question about whether there are any issues with directly calling attributes and/or methods of a threaded class instance. I wonder if someone could give me some advice on this. Generally, the documentation suggests that queues or similar constructs should be used for thread inter-process comms. I've had a lot of success...
8
1878
by: Steven Bethard | last post by:
I'm playing around with some threading stuff right now, and I'm having a little trouble calling a function from one thread that affects another. Here's my setup: py> import os, threading, time py> def write(file_in, input_lines): .... for line in input_lines: .... time.sleep(0.5) .... file_in.write(line) .... ...
0
1028
by: Raghul | last post by:
Hi friends, I am creating a jabber client and a separate class for dialog is created,So when the roster name is clicked this dialog open and can continue chat.What I need is I am calling the same class when reciving the message so that the application goes not responding.People told me to use threading for this. Can any one help me in...
3
362
by: Rob | last post by:
I have a vb form which calls a thread which makes webrequest calls into the internet, processes the info, and passes the info to another routine in another sub. It is stopping when it tries to make the sub call. The call is within itself or a sub in another dll. This problem is showing about 50%of the computers around the world. Is this an...
15
11743
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that performs the query is contained in a delegate function that I execute via a second thread. On 1 or 2 of the 600+ servers the query hangs. I've tried to...
5
4029
by: Homa | last post by:
Hi all, Can anyone give me some links about how to do an async web service call from aspx and display a temperary page before the web service returns? Thanks, Homa Wong
4
2458
by: barker7 | last post by:
In our app, we need to collect data at regular intervals (4, 8 or 16 seconds - user settable). The collection happens in a background thread. My first approach was to do the collection, which takes about 0.5 seconds, then calculate how much time to sleep until the next collection. The problem is that when I cancel the collection, I have to...
11
3176
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for Esa_Init. When I make a call, VS2005 reports "AccessViolationException" and refers to the 4th parameter (EsaT_State_Handle). I don't know how to...
0
3207
by: pinky22 | last post by:
I am calling SSIS package from a .Net windows UI. Both SSIS & .Net app are created in 2008. The SSIS package is stored in file system. When I ran .Net app I got error- The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object...
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7423
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7757
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.