Hi,
my current project is a train simulator. the application links into a hardware interface which allows the software to receive messages when inputs are activated (for example the brake control).
I think I am getting problems with multithreaded programming, let me explain :
my app uses 3 threads :
main thread - this deals with network messages, window messages and sound
positional updates - this deals with moving the camera through the world
control input - this deals with hardware inputs and the reactions it causes (eg to slow the train)
Task:
The user should press and hold the engine start button for 20 seconds.
If he lets go before 20 seconds the engine will not start.
Problem:
When the button is pressed, i start a timer at 50ms intervals.
The timerproc counts each interval and tests if the button was released and plays the relevant sound.
The problem is - some of my data is going funny. I have an array of sound object pointers (pre-initialised) and index 8 will always goto 0x00000064 on the line :
iTimerID[EngineStartTimer] = SetTimer(SysWin->hWnd,EngineStartTimer,INTERVAL,SystemTimerProc);
where:
iTimerID is a global array of int
SysWin is a window object (instanced in the same thread, uses wndproc in the same thread)
EngineStartTimer is a enumerated type (value 100)
INTERVAL = 50
SystemTimerProc is the TimerProc.
Any help greatly appreciated.
thanks,
Rich.
my current project is a train simulator. the application links into a hardware interface which allows the software to receive messages when inputs are activated (for example the brake control).
I think I am getting problems with multithreaded programming, let me explain :
my app uses 3 threads :
main thread - this deals with network messages, window messages and sound
positional updates - this deals with moving the camera through the world
control input - this deals with hardware inputs and the reactions it causes (eg to slow the train)
Task:
The user should press and hold the engine start button for 20 seconds.
If he lets go before 20 seconds the engine will not start.
Problem:
When the button is pressed, i start a timer at 50ms intervals.
The timerproc counts each interval and tests if the button was released and plays the relevant sound.
The problem is - some of my data is going funny. I have an array of sound object pointers (pre-initialised) and index 8 will always goto 0x00000064 on the line :
iTimerID[EngineStartTimer] = SetTimer(SysWin->hWnd,EngineStartTimer,INTERVAL,SystemTimerProc);
where:
iTimerID is a global array of int
SysWin is a window object (instanced in the same thread, uses wndproc in the same thread)
EngineStartTimer is a enumerated type (value 100)
INTERVAL = 50
SystemTimerProc is the TimerProc.
Any help greatly appreciated.
thanks,
Rich.