Windows 8 and how it breaks applications in South Africa!

Submitted by Robert MacLean on Wed, 10/10/2012 - 12:18

Before I start thank you to Mike Geyser for for bringing this up on Twitter.

Recently I wrote about what is the correct way to display currency in South Africa, which was meant as an interest post rather than anything related to Windows 8 or development – but it seems to be serendipitous in it’s timing. The post referred to the currency format and how you should use a comma to separate Rands & Cents. Windows has always (at least as far back as Windows 98) respected this as the correct currency format in South Africa.

Here you can see Windows 7 (left) and Windows 8 (right) have the same settings.

windows7currencywindows8currency

However with Windows 8, Microsoft have decided to be correct everywhere so if you compare the number format settings in Windows 7 (left) it uses a full stop where Windows 8 (right) uses a comma for number formatting.

windows7numberwindows8number

The problem is that the number format setting is used in .NET for parsing which means that all numeric code parsing code will break in Windows 8 if you have the South African formatting set!

var testOne = Decimal.Parse("10.2"); // works in Windows 7 and before - exception in Windows 8
var testTwo = Decimal.Parse("10,2"); // works in Windows 8 but fails in Windows 7 and before

The exception that will be raised is: System.FormatException: Input string was not in a correct format.

To be fair, Microsoft has said you should never write code like that, you should always provide the culture settings when parsing (this code always works):

var rightWay = Decimal.Parse("10.2", CultureInfo.InvariantCulture);

There are also two other ways to handle this:

CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
var anotherWay = Decimal.Parse("10.2");

In summary when going to Windows 8, make sure you properly test your applications and you test them on the culture that the users will use.

Windows Store app Development Snack: What do you get from being a lock screen app?

Submitted by Robert MacLean on Wed, 10/10/2012 - 11:29

For more posts in this series, see the series index.

When you start with development of Windows Store apps, you may want to run tasks in the background and an important aspect of that is deciding if you want to be a lock screen app or not.  Microsoft has a guide on this, which is ESSENTIAL reading so this post should be seen as a cheat sheet for a portion of that document.

Triggers

Background tasks kick off on a trigger so what triggers can lock screen & non-lock screen apps use. Non-lock screen apps can run background tasks based on

Background task trigger type

Trigger event

When the background task is triggered

MaintenanceTrigger

MaintenanceTrigger

It’s time for maintenance background tasks.

SystemEventTrigger

InternetAvailable

The Internet becomes available.

SystemEventTrigger

LockScreenApplicationAdded

An app tile is added to the lock screen.

SystemEventTrigger

LockScreenApplicationRemoved

An app tile is removed from the lock screen.

SystemEventTrigger

NetworkStateChange

A network change such as a change in cost or connectivity occurs.

SystemEventTrigger

OnlineIdConnectedStateChange

Online ID associated with the account changes.

SystemEventTrigger

ServicingComplete

The system has finished updating an application.

SystemEventTrigger

SessionDisconnected

The session is disconnected.

SystemEventTrigger

SmsReceived

A new SMS message is received by an installed mobile broadband device.

SystemEventTrigger

TimeZoneChange

The time zone changes on the device (for example, when the system adjusts the clock for daylight saving time).

Lock screen apps can use those and much more, the extra triggers for lock screen apps are

Background task trigger type

Trigger event

When the background task is triggered

ControlChannelTrigger

ControlChannelTrigger

On incoming messages on the control channel.

PushNotificationTrigger

PushNotificationTrigger

A raw notification arrives on the WNS channel.

SystemEventTrigger

ControlChannelReset

A network channel is reset.

SystemEventTrigger

SessionDisconnected

The session is disconnected.

SystemEventTrigger

UserAway

The user becomes absent.

SystemEventTrigger

UserPresent

The user becomes present.

TimeTrigger

TimeTrigger

A time event occurs.

CPU

Now we know when the background task will happen, how much CPU can background task consume during it’s execution is also affected by lock screen & non-lock screen.

Before we look at the table there is three things to know:

  • This is per app – NOT per background task!
  • Think of the refresh period as the point were we get filled up with more resources. So you can run multiple background tasks and they all consume from the pool of resources. At the refresh period the bucket is filled & any unused time will be lost.
  • CPU second is not the same as a real second. A CPU second is the amount of time that is consumed by the CPU – so if you are doing I/O (like a download) then it is not counted.

CPU resource quota

Refresh period

Lock screen app

2 CPU seconds

15 minutes

Non-lock screen app

1 CPU second

2 hours

Bandwidth

In a similar way to CPU the amount of data you can consume is also effected by being a lock screen app, but in addition to that the average speed of your internet also effects the amount of data. There is another difference to CPU, rather than one bucket – there is two:

  • Small period: The shorter amount of time and has a small amount it can be downloaded.
  • Day: The max per day – so accumulation of all the smaller ones cannot exceed this.

The table below has 1Mb & 10Mb as the average speed options but you could think of them as 1Mb = WiFi and 10Mb plugged into a network. These amounts are the top end, so if the network is slow you get less.

Average throughput Lock screen apps Non-lock screen apps
Every 15min Per day Every 2 hours Per day
1Mb/s 0.469Mb 4.69Mb 0.625Mb 7.5Mb
10Mb/s 4.69Mb 450Mb 6.25Mb 75Mb

Global Pool

Above we have looked at the resource constraints for CPU & bandwidth but what happens if that isn’t enough? Windows has a global pool of additional CPU & bandwidth resources that are shared system wide. This means that if you need 2.5CPU seconds you will likely get it! However the global pool is shared across all the apps, so it is not guaranteed (the above resources we have looked at are guaranteed). So if you have some abusive apps that use it, then your app may not get anything from the global pool. The global pool is replenished every 15min.

You can test your app works with an empty global pool, and you really should do this, by turning it off in the registry

Value name

Type

Default value

Description

HKEY_LOCAL_MACHINE\ SOFTWARE\Microsoft\Windows NT\CurrentVersion\BackgroundModel\Policy\CpuEnableGlobalPool

DWORD

1

Controls the CPU global pool. A value of zero disables CPU global pool.

HKEY_LOCAL_MACHINE\ SOFTWARE\Microsoft\Windows NT\CurrentVersion\BackgroundModel\Policy\NetEnableGlobalPool

DWORD

1

Controls the network global pool. A value of zero disables network global pool.

Control channel

Taken from Staying connected in the background.

The network trigger feature supports two possible resource types for a push notification or keep-alive network trigger:

  • Hardware slot - Allows the app to use background network notifications even in low-power or connected-standby mode.
  • Software slot - Allows the app to use background network notifications but not in low-power or connected-standby mode.

This notion of slot is integral to the network trigger and is not required for WNS.

One of the options to specify while registering for the network trigger feature is the hardware or software slot resource type. This resource type capability provides a way for your app to be triggered by an incoming notification even if the device is in low power mode. By default, a software slot is selected if the developer does not specify an option. A software slot allows your app to be triggered when the system is not in connected standby. This is the default on most computers.

On the other hand, a hardware slot allows your app to be triggered at all times including when the system is in connected standby. Only systems with network devices that support connected standby will have a hardware slot. Note that the app cannot be triggered through a software or hardware slot when the system is in Sleep or Hibernate mode, or is shut down.

An app can create and use a maximum of 5 network triggers. There is also an additional system limitation on number of network triggers that specify hardware slots. The first 3 lock screen apps that register for a hardware slot for a network trigger can use a maximum of 3 hardware slots per app. Any other lock screen apps beyond the first three apps registered for hardware slots are limited to only software slots for their network triggers.

Windows Store app Development Snack: Debugging a background task

Submitted by Robert MacLean on Tue, 10/09/2012 - 08:42

For more posts in this series, see the series index.

So you have created your background task and now you want to test it – do you wait for 15min and hope it runs? Nah – there is an easier way (which is unfortunately hard to find).

First launch your app as normal and then while it is running swop to VS (this is where multiple monitors is fantastic) and you should see the Debug  Location toolbar.

image

if you do not see it then right click on the toolbar/menu area and you will be able to enable it.

image

This toolbar is very useful to test Suspend & Shutdown scenarios for your application but what is not obvious is that if you click the little arrow next to the suspect button – all your registered background tasks will be listed there. You can then click it to kick it off immediately! Great for testing.

image

Pin-a-note

Submitted by Robert MacLean on Tue, 10/09/2012 - 08:06

Board Pin-190x190-100borderDo you wish you could stick a note to your start screen? NOW YOU CAN!

Pin-a-note, allows you to store your notes in this fantastic application, and then pin any to the start screen so you can easily seen them at any point!

Compared to the sticky notes gadget that is in Windows, this has some advantages & disadvantages – you have less text space but you save considerable memory, but notes automatically sync to all your devices and you can have non-pinned notes kept in the app too.

Download

This app is also in the Apptivate competition so please go there and vote for it by clicking the image below:

apptivate

Video

Screenshots

screenshot_10022012_205444screenshot_10022012_205502screenshot_10022012_205517screenshot_10022012_205607

Pin-a-Note makes use of icons created by the awesome (& free) Metro Studio 2.


Updates

16 October 2012

  • When you click edit/add the keyboard moves to the text field - allowing you to type straight away!
  • Hitting enter in the text box could be used to add/update the note!
  • Selecting a note will make AppBar visible if it currently isn't.
  • Clicking pin will show the progress ring while we render the note.
  • Included a training popup to help people get started!
  • Included an easy way to provide feedback.
  • Minor internal tweaks.

Windows Store app Development Snack: Stop asking for the SMS code when going to the dashboard

Submitted by Robert MacLean on Mon, 10/08/2012 - 13:29

For more posts in this series, see the series index.

imageWhen you get to publishing you may find it annoying to go to the dashboard as you are often being asked to put in a SMS code for verification.  The cause here is your browser is seen as insecure and thus you must confirm the login. So what is the solution?

  • Step 1: Make sure you login to Windows 8 with the same credentials as you use in the store.
  • Step 2: When you added you Microsoft Account to Windows 8, it would’ve emailed you a link to verify the computer. Make sure you have clicked that link.
  • Step 3: Use IE 10 and login to the dashboard.

And problem solved, now it will only ask you to login & confirm the login when the session expires!

Notepad Classic

Submitted by Robert MacLean on Fri, 10/05/2012 - 18:46

imageSometimes you just need a simple tool, for a simple job and while Microsoft offers the FANTASTIC OneNote MX available for Windows 8 to use, it may is just too much. With that in mind, let me introduce a simpler text editor, NOTEPAD CLASSIC!  Notepad Classic is that - a simple text editor! Enjoy

Download

Video

Screenshots

Notepad Classic makes use of icons created by the awesome (& free) Metro Studio 2.


Updates

15 October 2012

  • Made the menu act as the store app does, so you can hide them away now if you want.
  • Added colour options for foreground & background colours
  • Added some colour to the appbar
  • Added feedback & privacy policy links
  • Fixed the dirty flag (so less asking to save when not needed)
  • Status bar merged with menu bar.
  • Fixed the wrong font being used

Windows Store app Development Snack: What the age restriction for apps means to developers.

Submitted by Robert MacLean on Fri, 10/05/2012 - 09:16

For more posts in this series, see the series index.

I often think of age restrictions in, this is for adults only & this is for everyone however Microsoft has a far more complex view of the world:

  • 3+: Suitable for young child (three or above)
  • 7+: Suitable for ages 7 and older
  • 12+: Suitable for ages 12 and older
  • 16+: Suitable for ages 16 and older
  • Finally Adult Only apps

Content

Adult only apps are not allowed in the store – so we are only going to focus on the four other categories. The obvious aspect of ratings is content is a major influencer so for example at 3+ the content guideline is

These applications are considered appropriate for young children. There may be minimal comic violence in non-realistic, cartoon form. Characters should not resemble or be associated with real life characters. There should be no content that could be frightening, and there should be no nudity or references to sexual or criminal activity

While at 16+:

Apps with this age rating can depict realistic violence with minimal blood, and they can depict sexual activity. They can also contain drug or tobacco use and criminal activities, and more profanity than would be allowed in a 12+ app

None of that should be any surprise to any developer and just a bit of reading when you submit should keep you out of trouble.

Platform Access

The ratings have a second role, controlling what can & can’t be used! It is not until you reach 12+ can you access to online services, of personal information, or enable features such as microphones or webcams. This can get you into a bit of trouble when submitting.

My experience is that obvious online access is heavily controlled but I do have apps on 3+ that do access services (such as to load pictures). There is also nothing stopping your app on a technical level with these so it is something of an honour system which is maintained by the content review phase of submitting.

Windows Store app Development Snack: Knowing your (memory) limits, will avoid problems in the store!

Submitted by Robert MacLean on Thu, 10/04/2012 - 10:01

For more posts in this series, see the series index.

imageHere is a interesting requirement of Windows Store apps – they must run on a low-power computer, and if (like me) fail this you get the error message you see in the screenshot which suggests a test tool exists.

The problem with this tool is it can only test HTML apps :/ The question is then, what can XAML developers do to help avoid this situation? Use task manager – really. It is that easy! Just watch your memory usage while using your application once you have that there is two things you can do.

At the bottom of the Selling details page is the option to specify if you need more than 2Gb of RAM – which feels really high for the types of apps I build, but maybe worthwhile to those developing games. If you are over 2Gb of RAM, make sure you set that.

image

The second location is under the Description page which has a completely optional Recommended hardware

image

Here is some free form space for you to put in conditions about the application including things like disk space & memory usage. I resubmitted the app that failed originally with just this specified and it passed, so it appears that this is taken into account.

Windows Store app Development Snack: What's in a name?

Submitted by Robert MacLean on Wed, 10/03/2012 - 10:46

For more posts in this series, see the series index.

During development of Zune, then Windows Phone and finally Windows 8 the term Metro was used to define the UI design style, this was later extended to explain what a desktop app is versus a Windows 8 app is. However Microsoft has stopped using the name and recommended developers stop using the name too so what should we call these things?

Metro apps – these are now called Windows Store apps. Visual Studio uses this name too so shouldn’t be too surprising. Note one pedantic pro-tip: app’s is ALWAYS lowercase.

Metro as in the style – As I explained Metro started out as a way to explain the UI design, that is now known as the Microsoft design style.

Metro principals – Finally we often talk of the 8 traits or principals of a great Metro Windows Store app and one of those is Embrace Metro Windows design style principals:

  1. Show pride in craftsmanship
  2. Do more with less
  3. Be fast and fluid
  4. Be authentically digital
  5. Win as one

Source: http://msdn.microsoft.com/en-us/library/windows/apps/hh464920.aspx

Windows Store app Development Snack: Publishing your app, what has to be done before you publish?

Submitted by Robert MacLean on Tue, 10/02/2012 - 08:07

For more posts in this series, see the series index.

imageDevelopment is done and not just done, but done-done. You have logged into the Dashboard and want to submit your application – there are two things that must be done PRIOR to you publishing successfully, and both are on the right hand side menu under Profile.

Payout

Payout is used to setup which account money will be paid into – if this is not setup your app will not even go through certification! You may think this only applies to those doing paid apps – it doesn’t. ALL apps, even free ones, need this setup first.

When you do payout setup it is going to ask you for one of three values (from what I can gather):

  • Credit card CVV – the simplest option.
  • Transaction amount – Microsoft will put through a transaction on your account and you need to put in the cents portion of that amount.
  • Transaction code – Microsoft will put through a transaction on your account and you will need the magic code in the description.

Below is a screen grab from my account statement, so if they asked for amount it would be 29 and if they asked for code is would be 851.

image

There is two final points around payout that are vital to remember:

  • Limited attempts: You get a few attempts to put the number in. Get all these wrong and your account is locked. You will need to deal with support who must escalate for you to other teams and this will take DAYS.
  • Transactions take time: If you are not lucky enough to get a CVV check then you will get the one of the transaction checks. These can take time to appear, especially if you are not in America – so if you do not see it immediately, wait two days. DO NOT TRY AND GUESS because you will hit your limited attempts.

Tax

The second issue is tax – once again this must be completed by EVERYONE. However having invalid tax forms will not block certification, it will merely block publishing. The form is easy to use but an annoyance is that even after you complete it the status will remain invalid. It stays invalid until it is verified by the system. So read invalid as either not done or not processed.