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
RevLine 
[329]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
[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
[907]23#include "fm3str.h"
24#include "errutil.h" // Dos_Error...
25#include "strutil.h" // GetPString
[1163]26#include "timer.h"
[2]27#include "fm3dll.h"
28
[329]29static PSZ pszSrcFile = __FILE__;
30
[2]31static HEV hevTimerSem;
32
[551]33static void TimerThread(void *args)
[329]34{
[551]35 HAB hab2;
36 HMQ hmq2;
[2]37 ULONG cntr = 0;
38
39 priority_bumped();
40 hab2 = WinInitialize(0);
[551]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);
[2]58 }
59 WinDestroyMsgQueue(hmq2);
60 }
61 WinTerminate(hab2);
62 }
63}
64
[329]65//== StartTimer() return TRUE can start thread ==
[2]66
[551]67BOOL StartTimer(void)
[329]68{
[551]69 INT rc = _beginthread(TimerThread, NULL, 32768, (PVOID) 0);
[329]70
71 if (rc == -1)
[551]72 Runtime_Error(pszSrcFile, __LINE__,
73 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[329]74
75 return rc != -1;
[2]76}
77
[551]78void StopTimer(void)
[329]79{
[2]80 DosPostEventSem(hevTimerSem);
81}
[793]82
83#pragma alloc_text(TIMER,TimerThread,StartTimer,StopTimer)
Note: See TracBrowser for help on using the repository browser.