Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey,
I want to ask question about c++ win32 console multitasking.
I am working on making a game of chess, The program is completed, but i need to add animations by two or three tasks at the same time. Just like a constant running time somewhere on screen and the program should also stops for user input.

http://www.tutorialspoint.com/cplusplus/cpp_multithreading.htm[^]

I want something like this.This is much more easier. But I am unable to add pthread.h in visual studio 2010.
Posted
Updated 19-Nov-12 3:34am
v3

Then use worker threads. I suggest you reading J. Newcomer's assay on the topic "Using Worker Threads"[^] even if it is MFC oriented, you might gain some insight (e.g. the "don't touch the UI rule").
 
Share this answer
 
Comments
saad_lah 19-Nov-12 9:08am    
Very thnx for ur reply sir,
I have read the article, but i need some thing which is easy for me(i am beginner with threading).
I will be very grateful to u if u could send me a code of multithreading.
Espen Harlinn 19-Nov-12 9:39am    
5'ed!
If this is for UI animation only, you could use a regular timer, here is a small tutorial:
Timers Tutorial[^]

An event will be generated at intervals, lets say 100ms, which I guess will be good enough for your animations.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
saad_lah 19-Nov-12 9:46am    
Thnx sir, this has solved the timer problem.
Could u plz tell me how can i add pthread.h lib to visual studio, because i want to do more than one animation in my game. I googled but i failed to find the correct solution.
Espen Harlinn 19-Nov-12 9:51am    
Have a look at :http://www.cs.wustl.edu/~schmidt/ACE.html
download code + documentation - there is a wide range of examples available, and the library provides a wide range of "higher" level features that I guess you will find useful.

I've also written a "starter" project that you'll find useful: http://www.codeproject.com/Articles/143484/Integrating-ACE-and-ATL
Jochen Arndt 19-Nov-12 9:59am    
I already posted the answer to your solution, but it has been removed with the solution. The first hit when googling for 'pthread win32' is http://www.sourceware.org/pthreads-win32/.
saad_lah 19-Nov-12 10:12am    
@Jochen Arndt :: I got the link and I am now trying to link it with visual studio
saad_lah 19-Nov-12 10:06am    
Umm... Truly said, these are higher level features. I am beginner and studying C++ in University, but i will use ACE and ATL features in future :)
Thnx for ur help sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900