Krzysztof Mossakowski
Windows Programming
2005 - Tasks
Processes and threads
Sample task
Demonstration
Features:
The main window:
two "trains" - green moving horizontally and red moving vertically as in the demonstration
sizes and speeds of trains are random
tracks of both trains must collide int the center of window's client area
Technical issues:
use one thread per train
drawing code can be only in the procedure of the main window
don't let the scene flicker
use a semaphore or a mutex to synchronize trains
left mouse button stops/runs green train, right - red train
stopping the train means stopping train's thread
naciśnięcie prawego przycisku myszy - zatrzymanie/wznowienie ruchu czerwonego "pociągu"
don't let to resize the window
make sure that both threads are stopped before the program quits
using of a timer is forbidden
using busy waiting is forbidden
Hints:
CreateThread
CreateMutex, CreateSemaphore
WaitForSingleObject
ResumeThread, SuspendThread