source: trunk/dll/timer.c@ 907

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

Avoid out of memory traps in Compare Directories
Rework Compare Directories progress display for 2 second update rate
Start refactoring to reduce dependence on fm3dll.h
Add timer services (IsITimerExpired etc.)

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