source: trunk/dll/timer.c@ 551

Last change on this file since 551 was 551, checked in by Gregg Young, 18 years ago

Indentation cleanup

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