OnIdle

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

OnIdle

Postby 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! :)
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9711
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Re: OnIdle

Postby 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?
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Bex
 
Posts: 6268
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Re: OnIdle

Postby 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...
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9711
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Re: OnIdle

Postby Peke » Sun Jan 03, 2010 7:28 pm

Interesting any code samples for testing?
Best regards,
Pavle
MM Core Developer and Fan (check HAPPYMONKEYING Site)
Image
Image
Peke
 
Posts: 7559
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia

Re: OnIdle

Postby 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
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9711
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK


Return to Addons developer forum

Who is online

Users browsing this forum: No registered users and 1 guest