Link to home
Start Free TrialLog in
Avatar of devayani
devayani

asked on

CreateThread

/*definition*/
DWORD WINAPI CMailManagerDlg::CheckIt(LPVOID pParam)

/*CheckIt() is the function which should be called on different thread. There is no syntax error but new thread is not getting created.Please check the parameters passed to CreateThread as function is not working sucessfully*/

/*call to the thread function*/
 threadhandle = CreateThread(0,0,CheckIt,(LPVOID)(-2),0,lpThreadId);

Avatar of jhance
jhance

If your thread uses the C run-time library (which is typical) you should not use CreateThread.  Use beginthread/endthread instead to ensure proper initialization of the RTL.

Anyway, what is the return value to threadhandle?  Is there an error reported?
Certainly, you've declared CMailManagerDlg::CheckIt() as a static member of that class, right?

..B ekiM
1. You should have told us what error messages you got. Never never just say "It does not work" or "It is not working".

2. For MFC applications, you should use AfxBeginThread instead of CreateThread.

3. CheckIt needs to be either a static member function or a global function. This is because a non-static member function has an implicit parameter, which is the this pointer. Thus, it does not match the function prototype required by AfxBeginThread.
You might want to take a look at my article at CodeGuru, which demonstrates how to use AfxBeginThread.

Download a File Using URLDownloadToCacheFile
http://www.codeguru.com/internet/urlfile.shtml
Avatar of devayani

ASKER

There is no error i.e the biggest problem and CreateThread also
returns successful result.
If, as you say, there is no error then CreateThread is returning you a handle to the newly created thread.  There are only two possibilities with this call:

1) It returns an error
2) It returns a handle to the new thread.

Now perhaps the thread isn't running as you expect but I'd just be speculation on it since you don't seem to want to provide many details about what the problem is.
ASKER CERTIFIED SOLUTION
Avatar of abdij
abdij

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Where does this stand?  It's been about a month since you've told us anything, devayani.

..B ekiM
Hi,

I do have to agree with mikeblas. Please consider at the earliest.

No harm meant.

Thanx
Actually I was trying for other problems,but I will try at the earliest
and will inform you.