0

I have this class

class ConnectionManager()
{
    public:
        void Receive(); /* This method uses variables from this class */
} 

void _tmain()
{
    ConnectionManager* m_pConnectionManager = new ConnectionManager();
    /* the thread should be called here */
}

How do I create a thread that uses the receive method from the m_pConnectionManager object? I can't seem to figure it out with the other questions on Stackoverflow. I tried with this but it doesn't work:

std::thread receiveThread(&ConnectionManager::Receive);

I get this error:

error C2064: term does not evaluate to a function taking 0 arguments c:\program files (x86)\microsoft visual studio 11.0\vc\include\functional
Dries
  • 995
  • 2
  • 16
  • 45
  • You either need a `static` method or a class instance. – NPE Jun 12 '14 at 18:26
  • But if I have a static method the variables don't work. And I do have a class instance it's called m_pConnectionManager. If I make a thread with m_pConnectionManager->Receive() it throws another error – Dries Jun 12 '14 at 18:28
  • 1
    How about `std::thread receiveThread(&ConnectionManager::Receive, m_pConnectionManager);`? – NPE Jun 12 '14 at 18:30
  • That seems to have done it (it does not throw errors). Thanks a lot :) – Dries Jun 12 '14 at 18:30

0 Answers0