|
-
Aug 20th, 2001, 11:38 PM
#1
Thread Starter
Hyperactive Member
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??
-
Aug 20th, 2001, 11:57 PM
#2
What is it you are doing? Wouldn't it be easier to use the check or menu events to know when they change?
-
Aug 21st, 2001, 12:14 AM
#3
Thread Starter
Hyperactive Member
no no.. It hads to be constant.. Its like.. Kill stuff.. kill advertisements if they show up.. kill this window if it opens..click this button on this window if that window is showing. But it’s coded like if TheMenu.killADwindow.checked = true then Call (KillAdvertisements). Then if an advertisement window is showing then it kills it. So it kind of waits for the window, so the timer has to be continuously running. Now that’s just one example.
Does that make any since?
-
Aug 29th, 2001, 10:23 PM
#4
Thread Starter
Hyperactive Member
HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!
PLEASE!! SOME ONE HLEP ME!!!
-
Aug 30th, 2001, 02:32 AM
#5
Hyperactive Member
Cant u use:
Private Sub Check1_Click()
If check1.value = 1 then
' your code
end if
End Sub
-
Aug 30th, 2001, 11:18 PM
#6
Thread Starter
Hyperactive Member
nah man! read the 3rd post.. what is my 2nd post up on the page.
-
Aug 31st, 2001, 01:22 AM
#7
PowerPoster
Hi
I like a qtn where the word 'kill' is used a lot! 
Ok, so let me get this straight. A timer checks to see something happens. If it does it goes and does lots of code. But, meantime other timers (and this timer i presume) are still working. The timers are freezing cos it is all too much to cope with?
Assuming i understand that correctly... Say if Timer1 detects an event happening. Can u then turn off all other timers, process ur intensive code and then turn them back on again?
If there is a chance of something happening during ur intensive code then can u add doevents during that code and do a minimalist check for new events occurring and say set a boolean flag. So, when u get to the end of ur intensive code it could check if there is something more to do. Finally, the code would reset the timers.enabled to true and keep going.
Regards
Stuart
-
Aug 31st, 2001, 01:33 AM
#8
Addicted Member
You should use
DOEVENTS keyword
in any LOOP that you have, this way OTHER times can work at the same time.
for example:
for A=1 to 10
msgbox "Hay Mr. DJ!"
call timer2_timer()
doevents
next A
-
Aug 31st, 2001, 07:11 AM
#9
Fanatic Member
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
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|