MFC Multi-threading is working ... Now another problem :(
Ok, well, I got the MFC multi-threading working. I found some code on CodeProject.com. Now I have another problem. I defined my Listen() and Server() functions in my application's dialog class, and I had to make them 'static UINT Function()', etc. Now, when I use "AfxSocketInit(NULL)", where the parameter is "WSADATA*", it causes the problem. First, I used some code from CodeProject. It looks like this:
I have to use that so that I am able to access functions in the class from my 'static' member functions, since I can't directly access non-static class members from a static class member. When I do something similar to this:
CMyApplicationDlg *_this; // Class's 'this' pointer
It gives me an error, and when I do "Debug", I get this line, from sockcore.cpp (I think that's the filename):
// 'lpParam' is the parameter passed in "AfxBeginThread"
THREADSTRUCT *ts = (THREADSTRUCT*) lpParam;
// This causes the problem
I think it's because my thread functions (Listen() and Server()) cannot access the dialog class so they can use the dialog window as the socket window. If you can offer any help I would really appreciate it. :)
ASSERT(pState->m_hSocketWindow != NULL);
I think I already did that ... ?
Well, I create the listening (m_csListen) socket when the user clicks the "Start" button in my application. Then, it starts the "Listen()" thread. Inside the listen thread is where it calls "Accept()". You may be trying to tell me something else, but this is how I understand it.