Category Archives: Uncategorized

tl;dw Build 2015 – App Lifecycle: From Activation and Suspension to Background Execution and Multitasking in Universal Windows Apps

My too long; did not watch summary of another Build 2015 session I watched: App Lifecycle: From Activation and Suspension to Background Execution and Multitasking in Universal Windows Apps

Note this session covers quite advanced scenarios. I’ve only summarized new features in Windows 10 API here. For better understanding watching the full session is highly recommended.


What is part of the unified Windows Application Lifecycle?

Suspend and resume
Background execution
Resource management
System triggers and notifications

This application lifecycle model is same across all platforms supported by Windows 10, only with a minor differences based on the device performance, memory, etc.


Application Lifetime – app can be in 1 of 3 states:


Application receives events when transitioning between states, Except: Suspended->NotRunning. This has not changed since Windows/Phone 8.1.


Extended Execution

Previously if user switched from app A to app B, app A was suspended with no way to continue running.
In Windows 10 it’s possible to request Extended Execution from OS.
App must provide reason for extended execution: ExtendedExecutionReason.LocationTracking or SavingData or Unspecified
This is basically the replacement for background location tracking API in Windows Phone 8, that was missing in Windows Phone 8.1.

User can revoke the request for extended execution. Revoked events will have ~1 sec to clean up. Min time is guaranteed but opportunistic afterwards.

private async void OnSuspending(object sender, SuspendingEventArgs e)
    SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral();
    using (ExtendedExecutionSession session = new ExtendedExecutionSession())
        session.Reason = ExtendedExecutionReason.SavingData;
        session.Description = "Upload Data";
        session.Revoked += session_Revoked;
        ExtendedExecutionResult result = await session.RequestExtensionAsync();
        if (result == ExtendedExecutionResult.Denied)
        // Upload Data 
        var completionTime = await UploadDataAsync(session);

Background Execution

Same Background Task API from Windows/Phone 8.1 – extended with new Triggers in Windows 10:



Resource management

Opportunistic Background Tasks: Run for as long as resources are available, No guarantee of execution, ApplicationTrigger, MaintenanceTrigger, DeviceUseTrigger

Default Background Tasks: Guaranteed minimum execution time of 25 secs, Everything else: TimeTrigger, PushTrigger


Opportunistic Background Tasks serve as a replacement for Windows Phone 8 that had no replacement in Windows/Phone 8.1 ResourceIntensiveTasks.


In-Proc Background Tasks

Originally background tasks were executed in separate process – with separate memory cap. In Windows 10 it’s possible to define in-process background tasks – shares memory cap with the host process. This can be defined the Pacakge.appxmanifest.



Socket Trigger Tasks

Apps can have network connectivity and discoverability maintained while suspended or even terminated. Alternative to WNS triggered Tasks

How it works:

In foreground app process: Create/retrieve socket(s), Register background task to be woken up, Give socket to broker service as app is suspending, Take socket back from broker service at any time

On incoming network activity on brokered socket: Background task is triggered, Take socket back from broker service



Background processing is converged with Windows
There are lots of new things you can do
But resources are still limited

How to debug most common memory leaks on WP8

When developing Windows Phone application, which is more complex than just 3 screens and couple lines of text, you’ll probably face the well-known problems of memory leaks. Even when using modern platform as Windows Phone 8, without pointers, with Garbage Collector, IntelliSense and everything, it is still quite easy to experience memory leaks in your apps.

In this article I’ll go through 3 most common problems that are causing leaks when developing Windows Phone apps: Images, abandoned Pages and leaks in native controls. I’ll also shown you simple trick, how to find your leaks early in the development and not two weeks before project deadline 🙂

Continue reading

Hello world!

Migration of my BloQ to new system is complete – the old BloQ is now located on address It contains all previous posts and also new diary from our trip to Florida and Atlanta. Related photo gallery is here: photos from Kennedy Space Center.

Please note comments are now disabled on the old site. If you want to comment any posts from the old blog, just write it right below this article, thanks 🙂