Javascript function to find background task by name on Windows 8

FindTask: function (taskName) {
    var background = Windows.ApplicationModel.Background;
    var iter = background.BackgroundTaskRegistration.allTasks.first();
    var hascur = iter.hasCurrent;

    while (hascur) {
        var cur = iter.current.value;

        if (cur.name === taskName) {
            return cur;
        }

        hascur = iter.moveNext();
    }

    return null;
}

Posted

in

by

Tags: