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