source: trunk/dll/timer.c@ 1330

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