|
-
August 31st, 2007, 02:31 AM
#1
How Do I send Parameters to a Thread in Motion?
Hi
I am trying to figure out how to pass a parameter to a Thread . Specifically char*. I might not be explaining correctly, so here are some snippets of my code.
My main looks like this
Code:
int main()
{
ThreadManager tm;
tm.launchThread (&tm);
while(true)
{
// ... code to capture events and send char* parameters
// by some yet to be determined means to this thread.
}
}
//---------------------
class ThreadManager
{
private:
DWORD m_dwThreadID;
HANDLE m_hThread;
public:
ThreadManager();
~ThreadManager();
bool launchThread(ThreadManager *w);
HANDLE TheHandle(void) const;
static DWORD WINAPI ThreadFunc(LPVOID pvParam);
void close();
void shuttingDown();
};
implementation below
...
DWORD WINAPI ThreadManager::ThreadFunc(LPVOID pvParam)
{
SpecialThread sp;
SpecialThread.foo("Sample Parameter");
while(true)
{
}
}
I know this might look a bit weird. But it's necessary for me to keep main from being blocked by the activities of SpecialThread sp; It's a long story. That class just takes a couple seconds to do what it does and I can't have it freeze the app. I tried every work around and can't find one. With this solution SpecialThread launches and main() does not get blocked.
So here is the big question:
SpecialThread takes char* in foo(char* c );.
My hope is to figure out a way to pass a char* from main() through Threadmanager to SpecialThread a char* parameter.
Does anyone have any idea on how I could possibly do this ?
SpecialThread will be the only thread launched. So If I can just send some char* parameters to foo() I'll be finished.
Thanks in advance - will definitily be giving rep points for help on this one .
Stephen
Last edited by stephenprogrammer07; August 31st, 2007 at 02:34 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|