Windows 10

Microsoft’s 10 good and bad moves/decisions of 2018

Living day to day in the Microsoft world, I have some observations.
In no particular order, here are Microsoft’s 10 good and bad moves/decisions of 2018:

Thumbs down:

Microsoft Store
The store offers a 2nd class experience. Searching for an app does not always provide the best result. On a few occasions this year, Microsoft announced new apps but they were not yet available due to server propagation. The Store app’s design is not as good as its competitors.

Developer Partner Center
Through the year, the Partner Center where developers go to submit new apps or updates suffered from multiple bugs and delays in reports, and most of the time no status was given to help developers. In May, Microsoft announced that developers will receive 95% of revenue from their apps before the end of 2018, but this promise has yet to come true.

Native UWP apps in the Store
This year was the year of the desktop bridge based app. It started strong with the addition of iTunes in the Store catalog. However, I didn’t see tons of momentum of new native UWP apps. UWP apps still offer a 1st class experience when it comes to touch based apps. Electron seems to offer strong competition when it comes to cross platform desktop development. Twitch, Slack and Microsoft Teams have embraced Electron instead of UWP. I would like to see more momentum from 3rd party publishers.

Cortana
Microsoft entered into a surprising partnership with Amazon to have Alexa available in Windows 10. Alexa has a good market share so I’m still puzzled about what is next for Cortana. I don’t believe developers will jump into writing Cortana Skills when they can just write Alexa skills since Alexa is now available in Windows 10. The users have gained from the partnership, but Cortana itself has lost the consumer market battle.

The Windows 10 October Update

Edge
The December announcement that Edge will embrace Chromium was a big surprise. In short term, it seems like a defeat and in the short term, developers will be in for a bumpy transition until the new engine is ready. There is still a chance that this new strategy will pay off.

Windows Mixed Reality
This was a pretty quiet Windows Mixed Reality push. Many headsets are $200 off in the Microsoft Store. I didn’t see any major apps making big splashes in the news. Note: I have the same thought about Apple AR.

Windows S SKU
On paper, the idea was great, but preventing users from downloading legacy Win32 apps was probably a no-go to most consumers. At least, Microsoft didn’t spend years with this SKU and they just turned this SKU into a Windows option.

Windows on ARM
Qualcomm has a good chip that gives a good balance with CPU speed while preserving battery life while having Windows always on. Tablets were announced in February, but are not yet available in Canada. Microsoft still have in some area a US centric approach.

Skype
For an app that has as its core feature message delivery, I have been through many pains over the past year (and past years too). I have missed countless messages due to notifications that never showed up. I have seen messages in the wrong order. The UI changed often.

Thumbs up:

GitHub acquisition
It caused a major storm in the developer world (mostly to the non-Microsoft community members). It was considered an evil move like Microsoft used to do in the nineties, but Microsoft said out loud that GitHub will keep the same philosophy. In very short term, GitHub delivered new cool features and the trend is not stopping. Nat Friedman seems to fit perfectly as new GitHub CEO.

Surface lineup
The team delivered the Surface Go, Surface Studio 2, Surface Laptop 2, Surface Pro 6 and the new cool looking Surface Headsets. Panos confirmed that the brand is here to stay. I love the Surface lineup and the design keeps improving. Will 2019 deliver the not so secret Andromeda?

Xbox
Xbox One didn’t have the best start versus the PS4 few years ago, but today Microsoft keeps investing in new studios and promised exciting new hardware for gamers. Microsoft has the talent and the money to increase the future of gaming. They are also pushing the competitors to embrace cross-console play.

Employee reachability
If you are using the Microsoft stack and you are not on Twitter, you are doing it wrong! I see more and more employees interacting on Twitter with developers and mostly to help them. In the previous decade, in order to talk with a Microsoft engineer you had to deal with a leveling call support system and it was costly. Now, we are just 280 characters away from reaching an employee. I want to take the opportunity to thank everyone, you know who you are.

Azure Advocate team
I’m probably not wrong in saying that the Azure Advocate team has more than doubled this year alone. Azure itself is a non-contestable success story, but behind this there are humans helping developers to embrace the cloud. I like that Microsoft is doubling down in the cloud and doesn’t hesitate to invest in this space.

Open Source
It is not a secret anymore that Microsoft wants to be the best company when it comes to Open Source from Linux to Windows technology like WinForms, WPF and WinUI Library. At the end of the day, developers can even contribute to Microsoft stack to fix their own problem and have discussion about how to shape the future. It is a win-win for all.

MSDN Documentation
The documentation has improved greatly and now that it is mostly on GitHub, everyone can contribute and improve the help. Documentation is vital because it does not help to have the best technology if we don’t have the instructions on how to use it.

Machine learning and cognitive services
This is the technology of tomorrow that Microsoft is investing in today. The new text to speech engine blew my mind. I’m pretty sure that 2019 will deliver more services.

Revisiting old technology
Microsoft realized that WinForms and WPF are still popular technology. Instead of forcing developers to use newer technology, they did a turn around and proposed XAML Island to enable developers to use new UI controls of UWP in Win32 applications. They also have a roadmap for WPF and WinForms. That’s something that I haven’t seen for years.

Trust
No one would have said in January that Microsoft will be the most valuable company at the end of the year. Wall Street approves of Satya’s strategy more than ever and the numbers don’t lie. I have seem tons of positive articles about Microsoft and Satya than I ever have before. Satya is a down to earth person with a human touch and humility.

Have a good 2019!

Hang on!

Since the release of one of my UWP apps, the top crash was hang_quiesce.

image
Clicking on this failure, I was in confronted by a sea of nothing. I.E. nothing meaningful from my app and all Windows code.

image
I did a little survey among other UWP developers and some of them also confessed that this crash was quite common. It is good practice to fix crashes because if you have a high number of crashes, it affects the search ranking in the Microsoft Store.

I reached out to my friends at Microsoft. Stefan Wick was kind enough to tell me the possible causes: the app is hung or it forgot to release the deferral. Also, Brandon Paddock suggested a solution to the deferral issue: add the notion of duration of the App.OnSuspending event to force quit the execution after X time.

Note: I don’t know exactly how long the OS gives to the deferral before it takes the execution as hanging. This is probably not a good idea to do tons of database operations for example.

My simple solution was to introduce a delay task of 2 seconds and used Task.WhenAny to make sure that that either the Delay or Suspend method finishes before 2 seconds. For my app, it is not crucial if the Suspend method does not finish.

image

After one month, I was pleased to see this crash at 1.44% instead of 22%!

image

I don’t guarantee that your “hang_quiesce” issue will be the same as mine, but it is definitely worth a try.

Happy debugging!

NavigationCacheMode: A property that can save you a headache!

Windows 10 is here. There is no better time to start developing apps for the Windows 10 ecosystem.

If you are new to Windows 10 app development (or even 8.1 if you want to target Windows 8.1 / Windows Phone 8.1 users), there are some basic concepts that you need to learn: reactive design, application lifecycle, navigation, and so on.

This article is about one important property related to navigation (please continue to read!). If you develop an application that only has one page, you don’t have to worry about navigation. However, if your application has more than one page, you will need to use some navigation methods.

To illustrate the default behaviour of basic navigation, let’s create a Super Calculator application. You can download the sample here

1- Open any version of Visual Studio 2015 and go to “File \ New \ Project…” and select the template “Visual C# \ Windows \ Universal \ Blank App (Universal Windows)”. You can name the project “Super Calculator” and click OK.

image

2- Open the MainPage.xaml file and replace the Grid with:

<StackPanel
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    VerticalAlignment="Center">
        
    <TextBox
        x:Name="TextBoxNumber1"
        Width="200" />

    <TextBlock 
        Margin="0,10"
        Text="+"
        TextAlignment="Center"/>
        
    <TextBox
        x:Name="TextBoxNumber2"
        Width="200" />
        
    <Button Click="OnButtonCalculate"
            Content="Calculate"
            HorizontalAlignment="Center"
            Margin="0,10,0,0"/>

</StackPanel>

3- Open the MainPage.xaml.cs file and add the following method:

private void OnButtonCalculate(object sender, RoutedEventArgs e)
{
    int number1 = int.Parse(TextBoxNumber1.Text);
    int number2 = int.Parse(TextBoxNumber2.Text);

    this.Frame.Navigate(typeof(ResultPage), number1 + number2);
}

Here Frame.Navigate will navigate to the page specified with the type of the class.

4- Right-Click on the project SuperCalculator and select “Add \ New item… \ Blank Page”. Rename BlankPage1.xaml to ResultPage.xaml and click OK.

image

5- Open the ResultPage.xaml file and add the following inside the Grid:

<StackPanel 
    HorizontalAlignment="Center"
    VerticalAlignment="Center">

    <TextBlock
        Text="Result" />
            
    <TextBlock
        x:Name="TextBlockResult"
        FontSize="25"/>
            
    <Button 
        Click="OnButtonBack"
        Content="Back"
        Margin="0,10,0,0"/>

</StackPanel>

6- Open the ResultPage.xaml.cs file and add these two methods:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    TextBlockResult.Text = e.Parameter.ToString();
}

private void OnButtonBack(object sender, RoutedEventArgs e)
{
    Frame.GoBack();
}

Here Frame.GoBack will return to the previous page in the stack. In our case, it returns to the MainPage.

7- Run the application and put numbers in the 2 fields and click on the button Calculate.

You will see the expected result. However, what do you think will happen if you click on the Back button? There are 2 possibilities:

a) Navigation to the MainPage will include the numbers that you entered.
b) Navigation to the MainPage will reset the numbers that you entered.

If you are familiar with the Silverlight model, you know that returning to the MainPage will include the numbers. However, in Windows 10, the MainPage will be instantiated again and the numbers will be reset. The decision is debatable, but we have to deal with it and fortunately, Microsoft offers the property NavigationCacheMode if you want to override the default behaviour of instantiating the page again.

For the pages that you want to preserve in memory, you only have to add NavigationCacheMode=”Required” to the page declaration.

<Page
    x:Class="App2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App2"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    NavigationCacheMode="Required">

Note: don’t try to change the NavigationCacheMode outside the page declaration in XAML or in the constructor, it will not work.

The NavigationCacheMode offers the “Enabled” value that will preserve the page in memory if the cache limit of the frame is not exceeded. Personally, I prefer to set the value to “Disabled” or “Required” value.

There are lots of scenarios where you will set the NavigationCacheMode to Required. One example is when a page contains a GridView or a ListView with many items. If a user clicks on an item to consult the details on another page, don’t make him scroll again when he returns. Not only will the user’s experience be better, the page will return faster because there is nothing to load as everything is in memory.

If you want to know more about Windows 10, here is a list of great resources from Microsoft (all free):

Happy coding!