CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2004
    Posts
    170

    Red face 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(...)){}?

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757

    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

  3. #3
    Join Date
    Jun 2004
    Posts
    170

    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?

  4. #4
    Join Date
    Feb 2002
    Posts
    5,757

    Re: Thread and Message Loop again

    Check out MSDN.

    http://msdn.microsoft.com/library/default.asp

    Check out my website for software development links.

    http://www.dslextreme.com/users/kuphryn/links.html

    Kuphryn

  5. #5
    Join Date
    Oct 2012
    Location
    India
    Posts
    1

    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
  •  





Click Here to Expand Forum to Full Width

Featured