visual basic 6 timer problem
Posted on 2009-04-21
This may or may not be a Visual Basic timer problem, but as the "problem" seems to circle around it I will try my best to explain the problem.
First of all, my application uses 2 timers. For my debuging code all I do is place a textbox in my application and each timer just prints to the text box "TIMER 2" or "TIMER 4". Its just an easy way to verify the timers are working..
Now next up, is this all works fine in the VB6 editor, however, it always fails on a compiled exe.
On the compiled program, the timers both run for a few seconds, and timer 2 just simply stops. Timer 4 carrys on and I added in there a textbox debug which reports timer2 is enabled and the tick is 1000. However, timer2 I have just placing the words "TIMER 2" in the text box and it does not do it after a few seconds, even though timer 4 still functions and still reports timer 2 is enabled and the tick is 1000.
Now before you jump in with ideas please read this carefully...
Now I do have a GO and STOP button on my form, which can enable and disable both timers.. all works fine. When the timers are running it uses about 25% CPU power (the code does a lot so no problems there). Now when the timer 2 "stops" it runs the CPU to 100% and it appears the application has crashed and locked up. which I think it has at this point..
timer 4 is still running, still reports timer2 is enabled and tick is 1000. BUT... now when I click the STOP button which disables both timers.. the CPU is still maxed out.. if I click START again nothing happens..
Now this is not a fault in the code, as if you let the program cycle a couple of times, then STOP it, and START it again with the buttons, it works fine and cpu drops to zero as nothing is running.
This is a very difficult problem to explain, but the best way I can explain it is that the program partically crashes and timer2 stops working then maxes out the CPU.
Furthermore, when you try to exit the application, it actaully reloads itself which is really bizzare. But if you run the program a few seconds (before this "crash" problem) then close it, it all closes down correct.
But if you leave it running until this timer crash problem and try to quit the application, it just keeps reloading itself. then have to just end-task it.
Once this "timer crash" happens, the program does not function correctly at all. It can't function without timer2 operating, but as its not being triggered it shouldn't be using a high CPU useage. So I can only explain it as some strange partial crash.
again, the program will run for hours in the VB6 editor with no problems, but as soon as it is compiled, it refuses to operate.
The only other controls I use are the windows common controls , just the slider option, Winsock , which only runs once to check for updates on program load, and a vbprogress bar ocx.
I can't really post the entire program in here, but the actual program has been running for the past few weeks in the editor with no problems. As soon as its compiled it comes up with the strange timer crash problem.
I also tried running the compiled exe on another pc, and had the same problems on that one aswell, so its not local to my machine. I could send the exe to someone, but its coould be a bit of an epic to register everything related to it.
I'm not a newbie programmer, Though I confess ive not used VB6 for some time now, cant' imagine anything can be wrong as it works fine in the editor just not compiled.. so Im sure this is more than a simple coding problem ?