source: trunk/dll/timer.c@ 1163

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

Ticket 187: Draft 1: Functions only

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