Running Background Application on Windows IoT Core
<p>I have created a BackgroundTask to run a WebService, however if i run my solution with debugger attached, everything works fine, slowly, but fine. But when i hit start in the appmanager (webinterface) it always says "failed to start package [MYPACKAGEID]". So what am i missing? </p>

<p>Here is the complete project: <a href="https://github.com/naice/HomeAutomation.git" rel="nofollow">https://github.com/naice/HomeAutomation.git</a></p>

<pre><code>public sealed class StartupTask : IBackgroundTask
{
    internal static BackgroundTaskDeferral Deferral = null;

    public async void Run(IBackgroundTaskInstance taskInstance)
    {
        // 
        // TODO: Insert code to perform background work
        //
        // If you start any asynchronous methods here, prevent the task
        // from closing prematurely by using BackgroundTaskDeferral as
        // described in http://aka.ms/backgroundtaskdeferral
        //

        Deferral = taskInstance.GetDeferral();

        await ThreadPool.RunAsync(async workItem =&gt; {

            RestWebServer restWebServer = new RestWebServer(80);
            try
            {
                // initialize webserver
                restWebServer.RegisterController&lt;Controller.Home.Home&gt;();
                restWebServer.RegisterController&lt;Controller.PhilipsHUE.Main&gt;();
                await restWebServer.StartServerAsync();
            }
            catch (Exception ex)
            {
                Log.e(ex);
                restWebServer.StopServer();
                Deferral.Complete();
            }

        }, WorkItemPriority.High);
    }
}
</code></pre>