How to create indefinite number of UI-thread with MFC
-
hi, I need to create many UI-threads using MFC. Each thread must run all the time and is able to send/receive message with main thread. I assume that I will have to create a CMyThread:public CWinThread and create many instance of this class in function AfxBeginThread() for UI-thread. But I notice that this function doesn't allow programmer to pass parameters to the newly-created thread. So, how could I start those threads with different initial parameters ? (e.g pass a client address to each thread sothat each thread serve one client only) thanks for any help.
-
hi, I need to create many UI-threads using MFC. Each thread must run all the time and is able to send/receive message with main thread. I assume that I will have to create a CMyThread:public CWinThread and create many instance of this class in function AfxBeginThread() for UI-thread. But I notice that this function doesn't allow programmer to pass parameters to the newly-created thread. So, how could I start those threads with different initial parameters ? (e.g pass a client address to each thread sothat each thread serve one client only) thanks for any help.
GameProfessor wrote:
So, how could I start those threads with different initial parameters ?
Here is one way 1.Add a function to the CMyThread class say "Initialize()" 2.Create the thread in the suspended mode. 3.Call the Initialize() function and pass the parameters that you want to pass. 4.Resume the thread.
nave