Big Help Needed (Too much code)
I have a problem. I have a timer that runs at full speed all the time. It has a million things in it. Basicly if checks a bunch of menus to see of there checked or not, and if one is checked then it runs a function or sub. The only thing is that this timer does soo much, and runs through so many subs and functions it interfears with running other timers. I have slower timers freez on me. I KNOW FOR A FACT That my other timers never get turned off, they just freez. Now.... For my question...
I'm thinking I need a way to make this timer alone in a differnt project or a dll file, or 2nd project, or something. I need it appart from my project but i need it to interact with my project at high speed. What can I do? Is there anything at all??
Timer callbacks... Performance increase...
Use a Timer callback instead of lots of timers. It may add some performance increase. i.e.
VB Code:
'Coded by Digital-X-Treme, 2001. VB-Forums.
'In a module.
Option Explicit
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public m_Hwnd As Long
Public Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, _
ByVal dwTime As Long)
Select Case idEvent
Case 1
'Call Timer1_Code...
Case 2
'Call Timer2_Code...
Case 3
'Call Timer3_Code...
Case 4
'Call Timer4_Code...
Case 5
'Call Timer5_Code...
End Select
End Sub
Public Sub Kill_Timer(ByVal ID As Long)
KillTimer m_Hwnd, ID
End Sub
Public Sub Set_Timer(ByVal ID As Long, ByVal Milliseconds As Long)
SetTimer m_Hwnd, ID, Milliseconds, AddressOf TimerProc
End Sub
'In a form etc.
m_Hwnd = Form1.Hwnd
'Set timers.
Call Set_Timer(1, 1000) 'Create a timer with ID: 1, interal 1 second.
Call Set_Timer(2, 3000) 'Create a timer with ID: 2, interal 3 seconds.
Call Set_Timer(3, 6000) 'Create a timer with ID: 3, interal 6 seconds.
'Kill timers.
Call Kill_Timer(1)
Call Kill_Timer(2)
Call Kill_Timer(3)
Hope this helps. :)
Laterz