I Need To Run Some Functions In Background In My Windows Phone 8.1 App.
I Have Created A Different Project For Background Tasks In My Solutions.
But Application Is Crashing When I Try To Register Following BG Task.
Here is My Code To Register Task`
private async void TasksRegistration()
{
var taskRegistered = false;
var TaskName = "FirstBG";
// Checking If Task Is Already Registered..
foreach (var task in Windows.ApplicationModel.Background.BackgroundTaskRegistration.AllTasks)
{
if (task.Value.Name == exampleTaskName)
{
taskRegistered = true;
return;
}
}
var builder = new BackgroundTaskBuilder();
builder.Name = TaskName;
builder.TaskEntryPoint = "BackGroundTask.FirstBG";
builder.SetTrigger(new TimeTrigger(15, true));
await BackgroundExecutionManager.RequestAccessAsync();
BackgroundTaskRegistration Task = builder.Register();
}
Application Crashed On Last Line When I Try Register This Task.
I Have Written XML Code In .Appx Manifest.