BackgroundTaskRegistration internal exception in wp8.1

135 Views Asked by At

I don't know how to create background task in WindowsPhone 8.1. Here is a solution I found. But when I rewrited the could, it throw an internal exception at line

this.taskRegistration = BackgroundTaskRegistration.AllTasks.Values.First();"

Who can tell me why?

The exception as follow

System.InvalidOperationException
HResult=-2146233079
Message=Sequence contains no elements
Source=System.Core
StackTrace:
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
0

There are 0 best solutions below