Asked by:
No more status property on the object passed to the function that handles the completion of a background task

Question
-
Hello guys.
In the previous release, we could check for the completion status of a background task by checking the status property of the object passed to the function that handles the completed event fired by the BackgroundTaskRegistration object.
It seems like now we must pass this info through the local settings object. That being the case, do we still need to set the succeded property in the background task's worker?
thanks.
Luis Abreu
- Edited by Luis Miguel Abreu Monday, June 18, 2012 12:42 PM
Monday, June 18, 2012 12:41 PM
All replies
-
Yes, set the succeeded property to true!
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Tuesday, June 19, 2012 6:18 PM
Tuesday, June 19, 2012 6:18 PMModerator -
Hello again.
Here's my background task code:
(function () {
"use strict";
importScripts("//Microsoft.WinJS.1.0.RC/js/base.js");
var definicoes = Windows.Storage.ApplicationData.current.localSettings,
tarefa = Windows.UI.WebUI.WebUIBackgroundTaskInstance.current,
url = "http://www.myweather2.com/developer/forecast.ashx?uac=dLKt3wmgwg&output=json&temp_unit=c&ws_unit=kph&query=32.6333333,16.9";
tarefa.addEventListener("canceled", cancelou);
function cancelou(sender, e) {
definicoes.values["resultado"] = "cancelado";
tarefa.succeeded = false;
close();
}
WinJS.xhr({
url: url
}).done(function (req) {
var resposta = req.responseText;
definicoes.values["funcionou"] = true;
definicoes.values["resultado"] = resposta;
tarefa.succeeded = true;
close();
},
function (req) {
var erro = req.responseText;
definicoes.values["funcionou"] = false;
definicoes.values["resultado"] = erro;
tarefa.succeeded = false;
close();
});
})();And here's my completion callback and what I get in the event object:
And yes, I've changed the code, but in the previous release, it did work and state was indeed returned.
Luis Abreu
Tuesday, June 19, 2012 6:57 PM -
I am sorry Luis, I don't understand what the question is. I had thought I had answered it. Can you tell me what the question is since I thought it was whether you should set completed to true but that is apparently not it?
-Jeff
Jeff Sanders (MSFT)
Tuesday, June 19, 2012 7:25 PMModerator -
You've answered the last question, but what about the first part: no more status property in the object passed to the function which handles the completed event?
thanks again.
Luis Abreu
Tuesday, June 19, 2012 8:44 PM