locked
condition latching

    Question

  • Hello guys.

    I'm reading the background task white paper and I've reached this section:

    Condition latching behavior

    When a trigger is fired, the background task infrastructure checks whether all of the conditions are satisfied. If the conditions are not satisfied, the infrastructure waits until all the conditions are satisfied before executing the background task. This behavior is called latching because the background task infrastructure latches the trigger to a fired state.

    If a condition changes value while a trigger is latched, the background task infrastructure checks again to determine whether the conditions are satisfied for the background task. When all of the conditions are satisfied, it launches the task. For example, a background task that runs one hour from now with an InternetAvailable condition will run after the hour expires only if the Internet is available. When the time trigger fires, the background task infrastructure latches the trigger, but it does not run the task until the condition InternetAvailable is true.

    Now, the question: when will the trigger be removed from the latched state? After its associated task has been run once?For instance, in the previous example, let's suppose that the trigger fires and we'll only have internet 1 hour later:

    1st hour gone ->trigger fired and latched

    2st hout -> internet available, condition true ->task starts

    now what? has the trigger been removed from the latched state since the task has finally started? or will it still be in the latched state even though the background task has started?

    If this is the case, what happens if the timetrigger is set to 15mins and will only get internet within 1 hour?

    15mins -> tigger fired and moved into latched state

    30mins->trigger fires again? if so, now what? since its latched, it remains in that state?

    ..

    60->trigger fires again

    62 mins-> internet available, background task starts and trigger removed from latched state?

    thanks.


    Luis Abreu


    Friday, April 27, 2012 8:08 PM

Answers

  • Yes, once the task is launched, the latched state is reset. :-)

    Jeff Sanders (MSFT)

    Monday, April 30, 2012 12:09 PM
    Moderator

All replies

  • Nope:

    If a condition changes value while a trigger is latched, the background task infrastructure checks again to determine whether the conditions are satisfied for the background task. When all of the conditions are satisfied, it launches the task.

    1st hour, trigger fired, checks internet... Latches cause no connection

    +10 minutes... internet becomes available  " the background task infrastructure checks again to determine whether the conditions are satisfied for the background task. When all of the conditions are satisfied, it launches the task. "


    Jeff Sanders (MSFT)

    Friday, April 27, 2012 8:27 PM
    Moderator
  • Hello again Jeff.

    Yes, I think I understand that part (being in latched until all conditions are met and the task is fired). What I'm trying to confirm is what happens after the task is launched

    FOr instance, in the example, I assumed that 10 mins after the trigger is latched, we would get internet, the condition would be re-evaluated and the task would get launched. after theat (ie, after the task is launched), shouldn't the trigger be removed from the latched state?

    I guess I'm not sure about which question your "nope" refers to :)


    Luis Abreu

    Saturday, April 28, 2012 9:34 PM
  • Yes, once the task is launched, the latched state is reset. :-)

    Jeff Sanders (MSFT)

    Monday, April 30, 2012 12:09 PM
    Moderator
  • That's what I though!

    Thanks again Jeff.


    Luis Abreu

    Monday, April 30, 2012 1:27 PM