source: trunk/dll/timer.c@ 1213

Last change on this file since 1213 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
RevLine 
[329]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
[793]12 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[329]13
14***********************************************************************/
15
[907]16#include <process.h> // _beginthread
17
[2]18#define INCL_DOS
19#define INCL_DOSERRORS
20#define INCL_WIN
[907]21#define INCL_LONGLONG // dircnrs.h
[2]22
[1188]23#include "fm3dll.h"
[1213]24#include "mainwnd.h" // Data declaration(s)
25#include "datamin.h" // Data declaration(s)
[907]26#include "fm3str.h"
27#include "errutil.h" // Dos_Error...
28#include "strutil.h" // GetPString
[1163]29#include "timer.h"
[1188]30#include "misc.h" // PostMsg
[2]31
[329]32static PSZ pszSrcFile = __FILE__;
33
[2]34static HEV hevTimerSem;
35
[551]36static void TimerThread(void *args)
[329]37{
[551]38 HAB hab2;
39 HMQ hmq2;
[2]40 ULONG cntr = 0;
41
42 priority_bumped();
43 hab2 = WinInitialize(0);
[551]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);
[2]61 }
62 WinDestroyMsgQueue(hmq2);
63 }
64 WinTerminate(hab2);
65 }
66}
67
[329]68//== StartTimer() return TRUE can start thread ==
[2]69
[551]70BOOL StartTimer(void)
[329]71{
[551]72 INT rc = _beginthread(TimerThread, NULL, 32768, (PVOID) 0);
[329]73
74 if (rc == -1)
[551]75 Runtime_Error(pszSrcFile, __LINE__,
76 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[329]77
78 return rc != -1;
[2]79}
80
[551]81void StopTimer(void)
[329]82{
[2]83 DosPostEventSem(hevTimerSem);
84}
[793]85
86#pragma alloc_text(TIMER,TimerThread,StartTimer,StopTimer)
Note: See TracBrowser for help on using the repository browser.