OnIdle

Post a reply

Visual Confirmation

To prevent automated access and spam, you are required to confirm that you are human. Please place a check mark next to all images of monkeys or apes. If you cannot see any images, please contact the Board Administrator.

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: OnIdle

Re: OnIdle

Post by trixmoto » Mon Jan 04, 2010 4:26 am

Well it was whilst I was working on the latest version of my "Genre Finder" script, but something like this...
Code: Select all
Sub OnStartup
  Call Script.RegisterEvent(SDB,"OnIdle","Event_OnIdle")
End Sub

Sub Event_OnIdle()
  Call out("***OnIdle***")
End Sub

Sub out(txt)
  Dim wsh : Set wsh = CreateObject("WScript.Shell")
  Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
  Dim loc : loc = wsh.ExpandEnvironmentStrings("%TEMP%")
  If Right(loc,1) = "\" Then
    loc = loc&"GenreFinder.log"
  Else
    loc = loc&"\GenreFinder.log"
  End If 
  Dim logf : Set logf = fso.OpenTextFile(loc,8,True)
  logf.WriteLine(Time&" "&SDB.ToAscii(txt))
  logf.Close
End Sub

Re: OnIdle

Post by Peke » Sun Jan 03, 2010 7:28 pm

Interesting any code samples for testing?

Re: OnIdle

Post by trixmoto » Sun Jan 03, 2010 6:43 pm

I left it running and actually OnIdle continues to fire, it manages to fire a few hundred times between analysing the volume of each track but not during a single track by the looks of it. I don't need to know when MM is busy, I just want to say "fire once as soon as MM is idle" instead of "fire every time that MM is idle" and I can't work out how to do it. I might be able to use "Script.UnRegisterHandler" instead the Sub possibly...

Re: OnIdle

Post by Bex » Sun Jan 03, 2010 6:26 pm

I've never used it but it sounds a bit strange that it fires several thousand times. Perhaps it fires continuously when MM is idle? :)
If it would fire one time, don't you then need a OnNotIdle event? How can one otherwise know when the idle is over?

OnIdle

Post by trixmoto » Sun Jan 03, 2010 5:34 pm

Has anyone used the OnIdle event before? I thought it might do what I want but I'm struggling to control it. If I register it then it certainly waits until the rest of my script has run before it fires, but then it fires several thousands times back to back before stopping after a seemingly random number of fires.

How can I make it fire only once? For the timer event the object is passed in so that you can cancel it, but how do I cancel a specific OnIdle event?

Also, I've tested this whilst the file monitoring and volume analysing is going on, assuming that the event would not fire due to these tasks running, but it still fires. So when exactly is MM considered idle? Is it just when there are no scripts running code?

Any insights would be gratefully received! :)

Top