Re: How to PostThreadMessages?



You can't PostThreadMessage to a thread that does not have a message pump driving it..

Note that since the thread function is static, it has no CWinThread instance that would
allow a CWinThread::PostMessage to have any effect, so the compiler diagnostic is correct.

But if you come up with a workaround for that, then it won't work, because there's no
message pump.

You have to create a UI thread to handle this sort of thing, but it can't be doing
anything else interesting for any long period of time or the thread messages won't be
dequeued.
joe

On Mon, 4 Jun 2007 17:01:04 -0500, "jp2code" <poojo.com/mail> wrote:

I'm trying to create a CWinThread derived class.

To start the thread using AfxBeginThread, I had to declare my UINT Loop
function as static.

Now, how do I call other parts of my CWinThread derived class?

I have tried using PostThreadMessage, but this is an illegal call of a
non-static member function.

So, how do I call other parts of my class?

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: CAsyncSocket in service
    ... the sockets do not seem to run. ... console program that supports MFC and I use CStrings and MFC ... It can't support anything that uses a message pump directly. ... AfxBeginThread call of a UI thread specifying a CWinThread class, ...
    (microsoft.public.vc.mfc)
  • Re: CAsyncSocket in service
    ... the sockets do not seem to run. ... console program that supports MFC and I use CStrings and MFC ... It can't support anything that uses a message pump directly. ... AfxBeginThread call of a UI thread specifying a CWinThread class, ...
    (microsoft.public.vc.mfc)
  • Re: CAsyncSocket in service
    ... the sockets do not seem to run. ... console program that supports MFC and I use CStrings and MFC ... CWinThread does not seem to be running a message pump. ...
    (microsoft.public.vc.mfc)
  • Re: CAsyncSocket in service
    ... the sockets do not seem to run. ... console program that supports MFC and I use CStrings and MFC ... It can't support anything that uses a message pump directly. ... AfxBeginThread call of a UI thread specifying a CWinThread class, ...
    (microsoft.public.vc.mfc)
  • Re: Threads and Message Pump
    ... > if I will handle messages in MyThreadFunc then the function will look like ... The message pump is built into CWinThread. ... message handler suspends the thread again until the next message arrives. ...
    (microsoft.public.vc.language)

Loading