source: trunk/dll/timer.c@ 1221

Last change on this file since 1221 was 1213, checked in by John Small, 17 years ago

Ticket 187: Move data declarations/definitions out of fm3dll.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1
2/***********************************************************************
3
4 $Id: timer.c 1213 2008-09-13 06:53:06Z jbs $
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
12 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
13
14***********************************************************************/
15
16#include <process.h> // _beginthread
17
18#define INCL_DOS
19#define INCL_DOSERRORS
20#define INCL_WIN
21#define INCL_LONGLONG // dircnrs.h
22
23#include "fm3dll.h"
24#include "mainwnd.h" // Data declaration(s)
25#include "datamin.h" // Data declaration(s)
26#include "fm3str.h"
27#include "errutil.h" // Dos_Error...
28#include "strutil.h" // GetPString
29#include "timer.h"
30#include "misc.h" // PostMsg
31
32static PSZ pszSrcFile = __FILE__;
33
34static HEV hevTimerSem;
35
36static void TimerThread(void *args)
37{
38 HAB hab2;
39 HMQ hmq2;
40 ULONG cntr = 0;
41
42 priority_bumped();
43 hab2 = WinInitialize(0);
44 if (hab2) {
45 hmq2 = WinCreateMsgQueue(hab2, 0);
46 if (hmq2) {
47 WinCancelShutdown(hmq2, TRUE);
48 if (!DosCreateEventSem(NULL, &hevTimerSem, 0, FALSE)) {
49 for (;;) {
50 if (DosWaitEventSem(hevTimerSem, 3000) != ERROR_TIMEOUT)
51 break;
52 cntr++;
53 if (hwndTree && !(cntr % 3))
54 PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
55 if (hwndBubble && WinIsWindowVisible(hwndBubble))
56 PostMsg(hwndBubble, UM_TIMER, MPVOID, MPVOID);
57 if (DataHwnd)
58 PostMsg(DataHwnd, UM_TIMER, MPVOID, MPVOID);
59 }
60 DosCloseEventSem(hevTimerSem);
61 }
62 WinDestroyMsgQueue(hmq2);
63 }
64 WinTerminate(hab2);
65 }
66}
67
68//== StartTimer() return TRUE can start thread ==
69
70BOOL StartTimer(void)
71{
72 INT rc = _beginthread(TimerThread, NULL, 32768, (PVOID) 0);
73
74 if (rc == -1)
75 Runtime_Error(pszSrcFile, __LINE__,
76 GetPString(IDS_COULDNTSTARTTHREADTEXT));
77
78 return rc != -1;
79}
80
81void StopTimer(void)
82{
83 DosPostEventSem(hevTimerSem);
84}
85
86#pragma alloc_text(TIMER,TimerThread,StartTimer,StopTimer)
Note: See TracBrowser for help on using the repository browser.