multi-thread control in using loudmouth

20 views
Skip to first unread message

Xu Peter

unread,
Aug 25, 2009, 9:58:32 PM8/25/09
to loudmo...@googlegroups.com
Hi, everyone,
 
I am using loudmouth in an MFC application, in which I used the AfxBeginThread() to create a new thread for loudmouth, and my main thread doing the GUI work.
 
What should I do if I want to close the loudmouth thread in the main thread? I have got a rough search in the MSDN and found this:
 
 
It mainly tells that there are two ways to terminate a thread: First is the normal quit from the thread. The other one is called premature termination, which has to call the AfxEndThread() in the thread that would quit. So I can't use both methods, since the loudmouth thread is always in a g_main_loop_run() ...
 
I also noticed the sentence below in the upper URL:
 
"If you want to terminate a thread from another thread, you must set up a communication method between the two threads."
 
Maybe I can communicate with the LM thread with the GMainLoop structure?
 
Peter

alexant

unread,
Aug 29, 2009, 3:29:30 PM8/29/09
to Loudmouth Dev
This can help: http://mail.gnome.org/archives/gtk-app-devel-list/2006-March/msg00073.html

On Aug 26, 4:58 am, Xu Peter <xzpe...@gmail.com> wrote:
> Hi, everyone,
>
> I am using loudmouth in an MFC application, in which I used the
> AfxBeginThread() to create a new thread for loudmouth, and my main thread
> doing the GUI work.
>
> What should I do if I want to close the loudmouth thread in the main thread?
> Peter

Peter Xu

unread,
Aug 30, 2009, 1:28:48 AM8/30/09
to loudmo...@googlegroups.com
Thank you!

I have got though the problem by using CreateThread() instead of AfxBeginThread() to create a thread. It seems that the CWinThread cannot be directly killed by the main thread, but some other can.
Reply all
Reply to author
Forward
0 new messages