[329] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: timer.c 907 2008-01-06 07:26:17Z stevenhl $
|
---|
| 5 |
|
---|
| 6 | Timer thread
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
| 9 | Copyright (c) 2006 Steven H. Levine
|
---|
| 10 |
|
---|
| 11 | 22 Jul 06 SHL Check more run time errors
|
---|
[793] | 12 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[329] | 13 |
|
---|
| 14 | ***********************************************************************/
|
---|
| 15 |
|
---|
[907] | 16 | #include <process.h> // _beginthread
|
---|
| 17 |
|
---|
[2] | 18 | #define INCL_DOS
|
---|
| 19 | #define INCL_DOSERRORS
|
---|
| 20 | #define INCL_WIN
|
---|
[907] | 21 | #define INCL_LONGLONG // dircnrs.h
|
---|
[2] | 22 |
|
---|
[907] | 23 | #include "fm3str.h"
|
---|
| 24 | #include "errutil.h" // Dos_Error...
|
---|
| 25 | #include "strutil.h" // GetPString
|
---|
[2] | 26 | #include "fm3dll.h"
|
---|
| 27 |
|
---|
[329] | 28 | static PSZ pszSrcFile = __FILE__;
|
---|
| 29 |
|
---|
[2] | 30 | static HEV hevTimerSem;
|
---|
| 31 |
|
---|
[551] | 32 | static void TimerThread(void *args)
|
---|
[329] | 33 | {
|
---|
[551] | 34 | HAB hab2;
|
---|
| 35 | HMQ hmq2;
|
---|
[2] | 36 | ULONG cntr = 0;
|
---|
| 37 |
|
---|
| 38 | priority_bumped();
|
---|
| 39 | hab2 = WinInitialize(0);
|
---|
[551] | 40 | if (hab2) {
|
---|
| 41 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
| 42 | if (hmq2) {
|
---|
| 43 | WinCancelShutdown(hmq2, TRUE);
|
---|
| 44 | if (!DosCreateEventSem(NULL, &hevTimerSem, 0, FALSE)) {
|
---|
| 45 | for (;;) {
|
---|
| 46 | if (DosWaitEventSem(hevTimerSem, 3000) != ERROR_TIMEOUT)
|
---|
| 47 | break;
|
---|
| 48 | cntr++;
|
---|
| 49 | if (hwndTree && !(cntr % 3))
|
---|
| 50 | PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
|
---|
| 51 | if (hwndBubble && WinIsWindowVisible(hwndBubble))
|
---|
| 52 | PostMsg(hwndBubble, UM_TIMER, MPVOID, MPVOID);
|
---|
| 53 | if (DataHwnd)
|
---|
| 54 | PostMsg(DataHwnd, UM_TIMER, MPVOID, MPVOID);
|
---|
| 55 | }
|
---|
| 56 | DosCloseEventSem(hevTimerSem);
|
---|
[2] | 57 | }
|
---|
| 58 | WinDestroyMsgQueue(hmq2);
|
---|
| 59 | }
|
---|
| 60 | WinTerminate(hab2);
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
[329] | 64 | //== StartTimer() return TRUE can start thread ==
|
---|
[2] | 65 |
|
---|
[551] | 66 | BOOL StartTimer(void)
|
---|
[329] | 67 | {
|
---|
[551] | 68 | INT rc = _beginthread(TimerThread, NULL, 32768, (PVOID) 0);
|
---|
[329] | 69 |
|
---|
| 70 | if (rc == -1)
|
---|
[551] | 71 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 72 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
[329] | 73 |
|
---|
| 74 | return rc != -1;
|
---|
[2] | 75 | }
|
---|
| 76 |
|
---|
[551] | 77 | void StopTimer(void)
|
---|
[329] | 78 | {
|
---|
[2] | 79 | DosPostEventSem(hevTimerSem);
|
---|
| 80 | }
|
---|
[793] | 81 |
|
---|
| 82 | #pragma alloc_text(TIMER,TimerThread,StartTimer,StopTimer)
|
---|