By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,352 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

CreateThread or CWinThread

P: 5
Hello,

I need to implement a Thread in a Visual C++ 6.0 application. I've never done this, then I've been investigating, but I don't have any properly solution.

One of them is use CWinThread to comunicate to a Dialog but it has been already created. And the other possibility is create a thread with the function CreateThread(), but it gives me an error in the third parameter:

error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (class CDialogoPrimero *,void *)' to 'unsigned long (__stdcall *)(void
*)'
Would you mind pass me an example without this error?? the solution is doing the function "static" but it have another problems.

Thank you in advance.
Jun 6 '07 #1
Share this Question
Share on Google+
3 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
CreateThread requires that your thread functon is a ThreadProc.

A ThreadProc has this prototype:

Expand|Select|Wrap|Line Numbers
  1. DWORD WINAPI ThreadProc(LPVOID);
  2.  
That means you can have any function for a thread but is must have this prototype. For example:

Expand|Select|Wrap|Line Numbers
  1. DWORD WINAPI MyFunction(LPVOID date);
  2. DWORD WINAPI ThresholdDetector(LPVOID thedata);
  3.  
etc..

Then you can call CreateThread and use MyFunction or ThresholdDetector as the thread argument.
Jun 6 '07 #2

P: 5
Thank you very much.

But my problem was the following one:

error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)

I have to comunicate with a interface and I don't know how to do. I find it really difficult, although it musn't be so tricky.

Good day!!

CreateThread requires that your thread functon is a ThreadProc.

A ThreadProc has this prototype:

Expand|Select|Wrap|Line Numbers
  1. DWORD WINAPI ThreadProc(LPVOID);
  2.  
That means you can have any function for a thread but is must have this prototype. For example:

Expand|Select|Wrap|Line Numbers
  1. DWORD WINAPI MyFunction(LPVOID date);
  2. DWORD WINAPI ThresholdDetector(LPVOID thedata);
  3.  
etc..

Then you can call CreateThread and use MyFunction or ThresholdDetector as the thread argument.
Jun 7 '07 #3

P: 62
Hi,
Can just breif out the problem. because i wil also be working with multithreding concepts in VC++ 6.0.Just new to the community ans VC++.
Jun 7 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.