Canceling a timer

235 views
Skip to first unread message

Maddo

unread,
Jun 12, 2015, 2:04:20 AM6/12/15
to tas...@googlegroups.com
If I set a timer for example to go off in 4 hours is there any way to cancel it before the time is up?

Pent

unread,
Jun 12, 2015, 4:03:54 AM6/12/15
to tas...@googlegroups.com, cucciol...@gmail.com
System Timer ? No.

Pent

Maddo

unread,
Jun 12, 2015, 4:46:23 AM6/12/15
to tas...@googlegroups.com
I actually meant the Wait action inside a task, sorry for being too vague.

Anyway as a workaround I just devised a system in which to start a timer I make a task that will push an ID (for now %TIMEMS) + a status string ("Active", "Disabled", etc) to an array , then  the task waits x minutes (specified in %par1) and after it's done waiting it will check the array for its corresponding timer by the ID and if it doesn't exist anymore or the status is not "Active" then the task will just quit (and remove the array element) otehrwise it will perform the task specified as a name in %par2.

So my question actually is: Could I just cancel a task that is being waited or do I have to use a workaround like this?

Pent

unread,
Jun 12, 2015, 8:24:33 AM6/12/15
to tas...@googlegroups.com, cucciol...@gmail.com

So my question actually is: Could I just cancel a task that is being waited or do I have to use a workaround like this?

You can use action Stop. I can't remember if it interrupts Wait's or not, however.

Pent

Marco Giacomelli

unread,
Jun 12, 2015, 8:26:18 AM6/12/15
to tas...@googlegroups.com
Guess I'll have to experiments, I'll report on the results for future reference
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Tasker" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/tasker/b08lA-7t17Q/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> tasker+un...@googlegroups.com.
> Visit this group at http://groups.google.com/group/tasker.
> For more options, visit https://groups.google.com/d/optout.

Rich D

unread,
Jun 12, 2015, 8:22:12 PM6/12/15
to Tasker Google Groups Post


> Guess I'll have to experiments, I'll report on the results for future reference

From the guide....

Stop

Stop execution of one or more tasks after any currently running action has finished.

If a task is specified, then all tasks with the same name currently executing are stopped.

If no task is specified, the current task is stopped (but not other tasks with the same name).

If With Error is checked, the task(s) are marked as finished due to an error.

Note: to stop a different task will often require that it has a lower priority than the task with the Stop action, since otherwise the Stop action will perhaps never be executed.

********
Currently running actions in a different task will not be interupted by a Stop action, with the exception of Play Ringtone and a non-root Run Shell.
**********

So.. it is not clear what actually happens to the wait action itself , However I can confirm the task itself is stopped (exited) as soon as the stop action is preformed.

Hippo Man

unread,
Jun 12, 2015, 11:05:29 PM6/12/15
to tas...@googlegroups.com
The way I handle this is to write a task called "Wait" which takes a parameter specifying the number of seconds to wait.

That task repeatedly invokes a "Wait one second" action in a loop, until the specified number of wait seconds have elapsed.

Then, to put an interruptable wait into a task, I then just perform task "Wait", passing in the number of seconds. I can then kill this "Wait" task, and the wait will terminate after no longer than one second.
.

Hippo Man

unread,
Jun 12, 2015, 11:16:00 PM6/12/15
to tas...@googlegroups.com
... and here's another way to do it, if you have busybox installed.

Create a shell script called, for example, "/sdcard/wait-script" which takes the number of seconds as a command-line argument, and which looks like this:

#!/system/bin/sh
[[ $# -gt 0 ]] && {
  sleep $
{1}
}
exit 0



Then, to wait N seconds, use the "Run Shell" task to invoke this ...

/system/bin/sh /sdcard/wait-script N


To terminate the wait, use the "Run Shell" task to invoke this ...

/system/xbin/pkill wait-script

(I believe that busybox is needed to provide pkill)
.


Maddo Scientisto

unread,
Jun 13, 2015, 4:13:05 AM6/13/15
to tas...@googlegroups.com
won't that method of waiting one second kill the battery?
I need to wait for 4 hours every time, I can't have my phone keep
being awake to process wait events

Rich D

unread,
Jun 13, 2015, 8:26:40 AM6/13/15
to Tasker Google Groups Post

> won't that method of waiting one second kill the battery?
> I need to wait for 4 hours every time, I can't have my phone keep
> being awake to process wait events

Search this forum for a post with the t 'how to cancel an task' in the title. Then see Juergen's response.   It is the best approach for this.. IMHO..

Then to cancel you would just disable the profile...  

The post should not be very far down the forum list, it was a recent post..

Rich D

unread,
Jun 13, 2015, 8:41:09 AM6/13/15
to Tasker Google Groups Post

Ooppps. Got my titles mixed up. It should be
'how to create an task'

Any way here is a copy of the post... hope Juergen does not mind...

For a 90 minute delay I would prefer a profile with time context.

Task started by shortcut:

StartTimer (2)
    A1: Silent Mode [ Mode:On ]
    A2: Variable Set [ Name:%EndTime To:%TIMES + 5400 Do Maths:On Append:Off ]
    A3: Profile Status [ Name:Timer Set:On ]

Profile and Enter Task:

Profile: Timer (24)
    Time: From %EndTime Till %EndTime
Enter: Anon (25)
    A1: Profile Status [ Name:Timer Set:Off ]
    A2: Silent Mode [ Mode:Off ]

Juergen.

Reply all
Reply to author
Forward
0 new messages