C++ Thread Example

Need Help Regarding Thread in c++.

Please anyone give me the example of creating Pointer to ResumeThread of CWinthread

Thanks in Advaced..
John-Paul75Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John-Paul75Author Commented:
Its C++
0
AndyAinscowFreelance programmer / ConsultantCommented:
Start a thread as suspended, so it doesn't run yet
 CWinThread* pThread = AfxBeginThread (ThreadFunc, ptp,THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);

Some code here to manipulate the information the thread will require to operate correctly

Now let the thread actually work
 pThread->ResumeThread ();
0
AndyAinscowFreelance programmer / ConsultantCommented:
You could also look up MTRECALC in the help files.  It is an MFC example on using threads.  (I don't know if it actually uses ResumeThread but the other info may be worthwhile to look at).
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

sarabandeCommented:
if you mean function pointer it is

DWORD (CWinThread::*funcPtrResumeThread)() = &CWinThread::ResumeThread;

Sara




0
John-Paul75Author Commented:
No not like this something which include some overwriting of method.
0
sarabandeCommented:
ResumeThread is not a virtual function. you can overwrite it in your mfc application class which is derived from CWinThread but it won't be called from mfc framework.

you better explain what you intend to do. your keywords pointer, CWinThread, ResumeThread, overwriting don't give a senseful combination.

Sara
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantCommented:
>>No not like this something which include some overwriting of method.

Do you mean writing the function the thread will use to do the processing?
If yes then you can look at the MFC example MTRECALC for instance or this article at Experts Exchange:

http://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/A_3831-Sudoku-a-complete-MFC-application-Part-11.html

which uses a thread to perform a task and communicate with the main thread for display purposes.
0
John-Paul75Author Commented:
Thanks a lot but

Is their is any way to get the address of the CWinThread::ResumeThread() through respective DLL and store the address in a void pointer and resolve the reference by using late binding.

When I want to resume the thread I should use this pointer instead of ResumeThread();

Any Help in code format with explanation will appreciated.
0
AndyAinscowFreelance programmer / ConsultantCommented:
Much simpler to store the pointer to the thread and call ResumeThread from that.
0
sarabandeCommented:
CWinThread::ResumeThread()  is a member function. you need two pointers - the pointer to the CWinThread instance and the pointer to the member function to be able to call it later. that isn't 'late binding' as you can't do a virtual call of a member function via pointer. moreover, ResumeThread is not a virtual function as already told.

Sara  
0
AndyAinscowFreelance programmer / ConsultantCommented:
The reason given for deletion is self explanatory - nonsense.

I think the question has been adressed and answered/alternatives supplied.
0
John-Paul75Author Commented:
Sorry I was not really watching this question a long time after my posting
As I've solved my question.
So I would like to senior member please close this task.

Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.