Prev: Clipboard
Next: Winsock
From: Bee on
Experimenting with a timer class. The main loop looks like this.
Private Sub TimerLoop()

Do While Not m_bEnabled = False
If GetTickCount - m_lTickCount >= m_lInterval Then
RaiseEvent OnTimer
m_lTickCount = GetTickCount
ElseIf GetTickCount = 0 Then
m_lTickCount = 0
ElseIf GetTickCount < m_lTickCount Then
m_lTickCount = 0
End If
DoEvents
Sleep 1&
Loop

End Sub

I added the Sleep because the original code pushed the CPU useage to over
50% for this sub running.
Is this how the VB6 Timer control works?

(1)Is there a better way?
(2) how are timers allocated in windows?
i.e. is there a true max? or max per .exe ?
I know I have been told to consolidate but that is difficult in some
instances.

OK, so bottom line is this.
I have some hardware interfaces that do not have a way of doing an event
like the Serial OnComm does.
So I need to make an ActiveX EXE to interface with the manufacturer's .dll.
I want the ActiveX EXE to generate an event when there is a data change.
The data is sampled in the ActiveX EXE using my timer.
I could use a hidden form and a Timer control, but why not use an API like
above?

From: Karl E. Peterson on
Bee wrote:
> Is this how the VB6 Timer control works?

No.

> (1)Is there a better way?

Yes.

> (2) how are timers allocated in windows?

http://vb.mvps.org/samples/TimerObj

> i.e. is there a true max? or max per .exe ?

If you have to ask, probably.

--
..NET: It's About Trust!
http://vfred.mvps.org


 | 
Pages: 1
Prev: Clipboard
Next: Winsock