[Ace-users] Why the spawned thread must be waited?
gebenxiang at gmail.com
gebenxiang at gmail.com
Wed Oct 31 21:54:14 CDT 2007
Hi all,
I am developing a windows client with MFC and ACE. For user-
friendliness, the request to the server can be cancelled. I put two
threads in the client, one is for UI, the other is for network
commucation.
I want to use the active object pattern to handle the net
request:
1. The MFC message handler received a button-click event
2. The message handler creates an agent proxy and an
ACE_Future_Observer object
(exactly like %ACE_ROOT%/examples/apg/active_objects/AO2.cpp)
3. When the request completed, the ACE_Future_Observer object would
get the result, then notify the UI thread.
Now I face a problem: if I don't call ACE_Thread_Manager::instance
()->wait(), the spawned thread would crash; but when I call it, the UI
thread would be blocked (and it would succeed to get the result).
Why must we wait the spawned thread?
When activated it, I used the flag (THR_NEW_LWP | THR_DETACHED).
Best regards
John Ge
More information about the Ace-users
mailing list