source: trunk/dll/timer.c@ 689

Last change on this file since 689 was 689, checked in by Steven Levine, 18 years ago

Commit OpenWatcom compatibility updates

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