[329] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: timer.c 1880 2015-10-12 18:26:16Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Timer thread
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1335] | 9 | Copyright (c) 2006, 2008 Steven H. Levine
|
---|
[329] | 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
|
---|
[1335] | 13 | 10 Dec 08 SHL Integrate exception handler support
|
---|
[329] | 14 |
|
---|
| 15 | ***********************************************************************/
|
---|
| 16 |
|
---|
[2] | 17 | #define INCL_DOS
|
---|
| 18 | #define INCL_DOSERRORS
|
---|
| 19 | #define INCL_WIN
|
---|
[907] | 20 | #define INCL_LONGLONG // dircnrs.h
|
---|
[2] | 21 |
|
---|
[1188] | 22 | #include "fm3dll.h"
|
---|
[1227] | 23 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1213] | 24 | #include "mainwnd.h" // Data declaration(s)
|
---|
| 25 | #include "datamin.h" // Data declaration(s)
|
---|
[907] | 26 | #include "fm3str.h"
|
---|
| 27 | #include "errutil.h" // Dos_Error...
|
---|
| 28 | #include "strutil.h" // GetPString
|
---|
[1163] | 29 | #include "timer.h"
|
---|
[1188] | 30 | #include "misc.h" // PostMsg
|
---|
[1335] | 31 | #include "excputil.h" // xbeginthread
|
---|
[2] | 32 |
|
---|
[329] | 33 | static PSZ pszSrcFile = __FILE__;
|
---|
| 34 |
|
---|
[2] | 35 | static HEV hevTimerSem;
|
---|
| 36 |
|
---|
[551] | 37 | static void TimerThread(void *args)
|
---|
[329] | 38 | {
|
---|
[551] | 39 | HAB hab2;
|
---|
| 40 | HMQ hmq2;
|
---|
[2] | 41 | ULONG cntr = 0;
|
---|
| 42 |
|
---|
| 43 | priority_bumped();
|
---|
| 44 | hab2 = WinInitialize(0);
|
---|
[551] | 45 | if (hab2) {
|
---|
| 46 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
| 47 | if (hmq2) {
|
---|
| 48 | WinCancelShutdown(hmq2, TRUE);
|
---|
| 49 | if (!DosCreateEventSem(NULL, &hevTimerSem, 0, FALSE)) {
|
---|
| 50 | for (;;) {
|
---|
| 51 | if (DosWaitEventSem(hevTimerSem, 3000) != ERROR_TIMEOUT)
|
---|
| 52 | break;
|
---|
| 53 | cntr++;
|
---|
| 54 | if (hwndTree && !(cntr % 3))
|
---|
| 55 | PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
|
---|
| 56 | if (hwndBubble && WinIsWindowVisible(hwndBubble))
|
---|
| 57 | PostMsg(hwndBubble, UM_TIMER, MPVOID, MPVOID);
|
---|
| 58 | if (DataHwnd)
|
---|
| 59 | PostMsg(DataHwnd, UM_TIMER, MPVOID, MPVOID);
|
---|
| 60 | }
|
---|
| 61 | DosCloseEventSem(hevTimerSem);
|
---|
[2] | 62 | }
|
---|
| 63 | WinDestroyMsgQueue(hmq2);
|
---|
| 64 | }
|
---|
| 65 | WinTerminate(hab2);
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[329] | 69 | //== StartTimer() return TRUE can start thread ==
|
---|
[2] | 70 |
|
---|
[551] | 71 | BOOL StartTimer(void)
|
---|
[329] | 72 | {
|
---|
[1335] | 73 | INT rc = xbeginthread(TimerThread,
|
---|
| 74 | 32768,
|
---|
| 75 | (PVOID)0,
|
---|
| 76 | pszSrcFile,
|
---|
| 77 | __LINE__);
|
---|
[329] | 78 |
|
---|
| 79 | return rc != -1;
|
---|
[2] | 80 | }
|
---|
| 81 |
|
---|
[551] | 82 | void StopTimer(void)
|
---|
[329] | 83 | {
|
---|
[2] | 84 | DosPostEventSem(hevTimerSem);
|
---|
| 85 | }
|
---|
[793] | 86 |
|
---|
| 87 | #pragma alloc_text(TIMER,TimerThread,StartTimer,StopTimer)
|
---|