source: trunk/dll/timer.c@ 1227

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

Ticket 187: Moved typedef's and some #define's from fm3dll.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1
2/***********************************************************************
3
4 $Id: timer.c 1227 2008-09-13 23:13:11Z 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 "fm3dll2.h" // #define's for UM_*, control id's, etc.
25#include "mainwnd.h" // Data declaration(s)
26#include "datamin.h" // Data declaration(s)
27#include "fm3str.h"
28#include "errutil.h" // Dos_Error...
29#include "strutil.h" // GetPString
30#include "timer.h"
31#include "misc.h" // PostMsg
32
33static PSZ pszSrcFile = __FILE__;
34
35static HEV hevTimerSem;
36
37static void TimerThread(void *args)
38{
39 HAB hab2;
40 HMQ hmq2;
41 ULONG cntr = 0;
42
43 priority_bumped();
44 hab2 = WinInitialize(0);
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);
62 }
63 WinDestroyMsgQueue(hmq2);
64 }
65 WinTerminate(hab2);
66 }
67}
68
69//== StartTimer() return TRUE can start thread ==
70
71BOOL StartTimer(void)
72{
73 INT rc = _beginthread(TimerThread, NULL, 32768, (PVOID) 0);
74
75 if (rc == -1)
76 Runtime_Error(pszSrcFile, __LINE__,
77 GetPString(IDS_COULDNTSTARTTHREADTEXT));
78
79 return rc != -1;
80}
81
82void StopTimer(void)
83{
84 DosPostEventSem(hevTimerSem);
85}
86
87#pragma alloc_text(TIMER,TimerThread,StartTimer,StopTimer)
Note: See TracBrowser for help on using the repository browser.