Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Call method for NSTimer



On 1/31/06, Laine Lee <email@hidden> wrote:
> On 1/31/06 10:59 AM, "Mark Lively" <email@hidden> wrote:
>
> > NSTimers are used to trigger events to happen in the future.
> >
> > You have a few options to replace the missing delay.
>
> Thanks, Mark.
> >
> > 1) recode the entire thing to use the idle loop where you want to
> > delay.  This gets REALLY ugly REALLY fast if you have a lot of delays.
> >
>

Property myStatus:0

on idle
    if myStatus = 0 then
       doStuff1()
       display dialog "Waiting on more data" giving up after 1
       set status to status +1
       return 5 -- 5 second delay for more data
    else if myStatus = 1
       downloadData()
       startDetachedProcessing()
       set myStatus to myStatus +1
       return 30 -- Check for new data after 30 seconds
    else if myStatus = 7
       if checkStatus() then
            set myStatus to 1  --we have data
            return 1
       else
             display dialog "Processing stuck.  Aborting"
             set myStatus to 0 -- reinitialize
       end if
    else
         if checkStatus() then
              set myStatus to 1 -- process
         else
              set myStauts to myStatus + 1 -- wait a bit
         end if
         return 5
    end if
end

> This is what I think I have to try. Explanation follows, but can you direct
> me to an example of that implementation?
>
> > 2) Tell some other application who can see the standard additions to
> > delay.  (tell application "Finder" to delay 5)
>
> In 10.4.4, I still see error -1762 the first time that command is called. Am
> I doing something wrong?
>
I created a simple ASS application.


on idle theObject
	display dialog 1
	tell application "Finder" to delay 5
	display dialog 2
	return 1
end idle

It display both dialogs 5 seconds apart.

> >
> > 3) Roll your own
> >
> > on MarksDelay(n)
> > set laterTime to (current date)+n
> > repeat
> >     if (current date) > laterTime then exit repeat
> > end
> > end
>
> This one slows my machine down and makes the process I'm monitoring take
> much longer to finish.

That it would.


-Mark
Time to get back to work...
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >Re: Call method for NSTimer (From: Mark Lively <email@hidden>)
 >Re: Call method for NSTimer (From: Laine Lee <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.