473,569 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get a thread's handle

i want to use the API:
PostMessage(Int Ptr hWnd, int Msg, int wParam, int lParam)
to post message to a thread.
so i need the thread's handle.
thanks!
Nov 15 '05 #1
5 16321
The syntax of this function is:
BOOL PostMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
where hWnd is a handle to a window.
If you want to post a message to a thread you should take a look at
BOOL PostThreadMessa ge(
DWORD idThread,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);

"huajiao" <xi********@hot mail.com> wrote in message
news:03******** *************** *****@phx.gbl.. .
i want to use the API:
PostMessage(Int Ptr hWnd, int Msg, int wParam, int lParam)
to post message to a thread.
so i need the thread's handle.
thanks!

Nov 15 '05 #2

well,i see.
but how can i get the idthread in c#?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3
but how can i get the idThread in c#?


AppDomain.GetCu rrentThreadId()

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #4
Does that return the actual OS thread id? I was under the impression that
it was an internal logical thread id since the mapping of the managed thread
object to the OS "real" thread used can change.
"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:ul******** ******@TK2MSFTN GP11.phx.gbl...
but how can i get the idThread in c#?


AppDomain.GetCu rrentThreadId()

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Nov 15 '05 #5
Does that return the actual OS thread id?


Yes it does (currently). But it might not be guaranteed to do so in
future versions.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #6

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

Similar topics

5
1306
by: Maximus | last post by:
Hi, I'm trying to create a thread (never did before) to constantly look at a combo box value but my thread take 100% of the processor, a thing I don't want to. First is it normal and second if first is no what's my error in my codes: int test = 0; {....} HANDLE thread = createTriggerThread((void*)HWnd); if(NULL!=thread)
4
2041
by: Rajiv Das | last post by:
Environment: Visual Studio 2005, Beta 2 ..Net 2.0 Windows XP, SP2 C# Generics ------------------------------- Hi, I have a Windows Form whose contents I would like to dynamically change. I
1
1225
by: Tom | last post by:
First of all, is it 'legal' (i.e. thread-safe) to pass events back from a worker thread to the main thread? I.E. Can one put PUBLIC EVENT XYZ in their worker thread and then raise that event for processing back in the main thread? I believe this is OK, but I want to check first... Secondly, if this is 'legal', what happens in the following...
5
4750
by: zxo102 | last post by:
Hi, I am doing a small project using socket server and thread in python. This is first time for me to use socket and thread things. Here is my case. I have 20 socket clients. Each client send a set of sensor data per second to a socket server. The socket server will do two things: 1. write data into a file via bsddb; 2. forward the data to...
1
5469
by: Frank Millman | last post by:
Hi all I am doing something which works, but I have a gut feel that it cannot be relied upon. Can someone confirm this one way or the other. I have a multi-threaded server, which responds to client logins and sets up a thread for each active session. A thread can stay active for a long time. I use a subclass of threading.Thread to...
1
4610
by: =?Utf-8?B?SkE=?= | last post by:
I use a method for threading that instantiates an object that is a wrapper to a DLL (written in C). The wrapper class is passed a byte array, and then does GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); IntPtr ptr = (IntPtr)(handle.AddrOfPinnedObject().ToInt32() + buffer.Length-1); It passes ptr to the DLL function...
18
10209
by: =?Utf-8?B?VGhlU2lsdmVySGFtbWVy?= | last post by:
Because C# has no native SSH class, I am using SharpSSH. Sometimes, for reasons I do not know, a Connect call will totally lock up the thread and never return. I am sure it has something to do with weirdness going on with the server I am talking to. Anyhow, this locked up state happens once in a while (maybe once per day) and I can't...
3
2261
by: Cartoper | last post by:
My application appears to have a recourse leak. When the user starts a background process, the handle count in Process Explorer (PE) goes up by about 10, sometime 1 or 2 more, sometimes 1 or 2 less. When the task is completed, there are somewhere between 4 and 7 handles still open. My process is loading images and shrinking them down. I...
3
1767
by: ekailan | last post by:
I am working on creating windows.h to creat tow threads, each thread takes tow files as input, the function that each thread excute is tested and work 100%,the problem is that one thread could work at atime ? I mean one function is excuted this is the threading code i dont know what is the problem. I tried to pass different files to each thread...
0
7618
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...
1
7678
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
7982
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
6286
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...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
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
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.