|
|
|
date: Tue, 03 Jun 2008 13:55:10 +0200,
group: microsoft.public.win32.programmer.ui
back
APC from one Window to another Window
Hi,
i am a newbie in Win32 Api programming, but have some experience in
Dotnet. My problem in Dotnet is very simple to explain. I have two
thread and want to call one function within the other thread. In Dotnet
i would write:
window1.Invoke(new SomeDelegate(myFunctionToInvoke), someArgsAsArray);
But now i try this in Win32 Api. I have created first a second thread
(createThread()) in that thread a second window (createWindow(),
showWindow()) and now i want to call some functions in my main thread
when a specific window message arrives in my WndProc. I found something
like QueueUserAPC(), but when calling this function with my main thread
handle as argument my apc function is not called :(
I have only the thread handle of my main thread, which i want to call.
By the way, i think, i need also a critical section, because i need to
transfer some data from the thread to the main thread function. Can i
get therefor also some assistants? Pleseeee.
Please help me. In Dotnet is everything so simple. Hats off for the
Dotnet Developers, which slog one's way through this api ;)
-Robert
date: Tue, 03 Jun 2008 13:55:10 +0200
author: Robert-Reinhold Groß
Re: APC from one Window to another Window
You should read the documentation and articles and samples. This subject is
one for which there is an abundance of articles and samples.
Note that it would help if you stated explicitly that you are using Java. I
am not sure how closely that createThread corres[onds with CreateThread but
createThread is not the Windows API and I assume that createThread and other
Java packages or classes or whatever are off-topic for this group.
If you do use the Windows API using C/C++ then be sure to read all the
relevant documentation. One thing in particular to read carefully and
thoroughly is the CreateThread documentation, since it clearly states that
CreateThread should not be used in a "thread that uses functions from the C
run-time libraries".
Also, when using the Windows API, a critical section is a common solution
and is liklely a good one for you. If you look in the Windows API
documentation you will find a section about processes and threads. There is
much useful information there. One thing that will likely help is events;
look at the documentation of them. You can look at my sample, but there very
many more you can find when you search for them.
Sample _beginthreadex
http://simplesamples.info/Windows/_beginthreadex.php
"Robert-Reinhold Groß" wrote in message
news:u97$tCXxIHA.1504@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> i am a newbie in Win32 Api programming, but have some experience in
> Dotnet. My problem in Dotnet is very simple to explain. I have two thread
> and want to call one function within the other thread. In Dotnet i would
> write:
> window1.Invoke(new SomeDelegate(myFunctionToInvoke), someArgsAsArray);
>
> But now i try this in Win32 Api. I have created first a second thread
> (createThread()) in that thread a second window (createWindow(),
> showWindow()) and now i want to call some functions in my main thread when
> a specific window message arrives in my WndProc. I found something like
> QueueUserAPC(), but when calling this function with my main thread handle
> as argument my apc function is not called :(
>
> I have only the thread handle of my main thread, which i want to call. By
> the way, i think, i need also a critical section, because i need to
> transfer some data from the thread to the main thread function. Can i get
> therefor also some assistants? Pleseeee.
>
> Please help me. In Dotnet is everything so simple. Hats off for the Dotnet
> Developers, which slog one's way through this api ;)
>
> -Robert
>
date: Tue, 3 Jun 2008 10:30:43 -0700
author: Sam Hobbs _change_social_to_socal
|
|