Click to See Complete Forum and Search --> : Problem with Timer Control


Sayan Mukherjee
March 13th, 2001, 09:24 PM
Hi Codegurus,

I am facing a weird problem with the timer
control of VB.

I have a VB form which has the timer in it. The
timer is set to 5 seconds interval. When this
5 sec expires, the Timer() method is called by
the VB framework automatically.

The Timer() method has a COM server method call
in it. So every 5 seconds the server method call
should take place.

If I run the application in the debug mode (by
pressing F5 button from the VB Design menu),
there is no problem; but if I compile the EXE
and run it from the desktop, the timer function
fires only once. The entire Form freezes after
this and there is no response on the Form.

Just for information:
- The COM object is instantiated using
CreateObject()

- I am running this application on
Windows 2000

- The server side code is written in VC 6.0.
I have used the ATL COM wizard for building
the class and the interface (i.e. the skeleton
code)

What could be the reason for this? If this is a
VB bug, please suggest a workaround. This is
really URGENT!!!!!

Thanks in advance,

With best regards,
Sayan

Sayan Mukherjee
Calcutta (INDIA)
Email: sayan1968@yahoo.com

CK Dixon
March 14th, 2001, 05:58 AM
Maybe a DoEvents within the Timer() event handler works for you.

Clearcode
March 14th, 2001, 06:07 AM
I wouldn't advise that - what happens if the timer fires whilst it is still processing the last firing and gets to the doevents()? Probably "out of stack space".

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com

Sayan Mukherjee
March 15th, 2001, 06:39 PM
The timer function should not fire before it
has finished processing the last firing. The
time count down starts all over only after
the TimerName.Timer() method returns.

So if the timer is enabled, there has to be at
least a finite time gap between two successive
calls to the TimerName.Timer() method.

However I found a work around to my problem.
I registered my server dll again and everything
was fine! I don't know what went wrong. I am
still apprehensive that the code can give
problems when it runs in the MTS.

Please throw some light on the problem. I would
like to be preventive rather than be sorry later!

With best regards,

Sayan

Sayan Mukherjee
Calcutta (INDIA)
Email: sayan1968@yahoo.com