browse: forums | FAQ
Connecting Tech Pros Worldwide

Hey there! Do you need C# / C Sharp help?

Get answers from our community of C# / C Sharp experts on BYTES! It's free.

how to get a thread's handle

huajiao
Guest
 
Posts: n/a
#1: Nov 15 '05
i want to use the API:
PostMessage(IntPtr hWnd, int Msg, int wParam, int lParam)
to post message to a thread.
so i need the thread's handle.
thanks!



codewriter
Guest
 
Posts: n/a
#2: Nov 15 '05

re: how to get a thread's handle


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 PostThreadMessage(
DWORD idThread,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);

"huajiao" <xiaohefeng@hotmail.com> wrote in message
news:03ec01c35a44$d07e9b20$a301280a@phx.gbl...[color=blue]
> i want to use the API:
> PostMessage(IntPtr hWnd, int Msg, int wParam, int lParam)
> to post message to a thread.
> so i need the thread's handle.
> thanks![/color]


hua jiao
Guest
 
Posts: n/a
#3: Nov 15 '05

re: how to get a thread's handle



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!
Mattias Sjögren
Guest
 
Posts: n/a
#4: Nov 15 '05

re: how to get a thread's handle


[color=blue]
>but how can i get the idThread in c#?[/color]

AppDomain.GetCurrentThreadId()



Mattias

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

re: how to get a thread's handle


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" <mattias.dont.want.spam@mvps.org> wrote in message
news:uljTEvmWDHA.2268@TK2MSFTNGP11.phx.gbl...[color=blue]
>[color=green]
> >but how can i get the idThread in c#?[/color]
>
> AppDomain.GetCurrentThreadId()
>
>
>
> Mattias
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/
> Please reply only to the newsgroup.[/color]


Mattias Sjögren
Guest
 
Posts: n/a
#6: Nov 15 '05

re: how to get a thread's handle


[color=blue]
>Does that return the actual OS thread id?[/color]

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.
Closed Thread