-
March 18th, 2005, 04:07 AM
#1
Thread and Message Loop again
Hi,everyone.
I read forums and msdn but still don't understand this question:
In MSDN says that all thread have message loop if it owns at least one window. So Where i can find this message loop how can i run it? Or i have to create message loop my self like : while(GetMessage(...)){}?
-
March 18th, 2005, 10:51 AM
#2
Re: Thread and Message Loop again
In theory, a worker thread does not have a message queue. In practice, PeekMessage() will create a message queue for a thread.
Kuphryn
-
March 21st, 2005, 12:44 AM
#3
Re: Thread and Message Loop again
Sorry,in my question i mean another. I want to ask
1)how to run thread message loop?
2)how it look like?
3)what it do with thread and window messages?
4)what relation between thread message loop and windows(windows which in this loop) message loop?
-
March 21st, 2005, 10:26 AM
#4
Re: Thread and Message Loop again
-
October 30th, 2012, 03:49 AM
#5
Re: Thread and Message Loop again
Hello
how to run thread message loop?
Looper Class used to run a message loop for a thread.
Threads do not have message loop associated with them.
so to create one call Prepare() using Looper class to run a message loop.
then loop() process all the messages associated with message loop until the loop has stopped.
Example:-
Class LooperThread Extends Thread{
Public Handler mhandler;
public void run(){
Looper.prepare();
mhandler = new Handler{
public void handleMessage(Message msg){
//... process all the messages here
}
};
Note :- This is the way to create Message Looper in Android using Java.
Thanks,
Looper.loop();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|