The Timer object allows you to measure the duration of an application operation. The duration is logged with the timestamp of the event and a key value that can be used for filtering analytics.

There are two ways developers can handle the Timer object:
  • Call the static void TimeStart (string key) and static IAsyncAction/Task (string key) APIs. The library stores the Timer object, which is invisible to the application developer. The library keeps the timer in memory and persists it into the secure store when static IAsyncAction/Task TimeEndAsync(string key) is called. The key is mandatory and must be unique for each timer.
  • Call the static Timer MakeTimer(string key) API, which creates a timer instance and returns to the application layer. The application stores the timer; the library does not keep references to it. To stop and persist the timer, the application calls static IAsyncAction/Task StopTimerAsync(Timer timer). The key can be empty or duplicated.

The API timer is an object with a timestamp and a method to stop the timer, which sets the timer interval to the current time and saves the duration. After the timer stops, the Timer object is saved in the secure store.


The developer wants to know how long it takes to download a very large file.

Create a timer before starting the download, then call TimeEndAsync when finished.

Usage.TimeStart ("DownloadTimer")
var downloadedFile = await GetHugeFileAsync();
await Usage.TimeEndAsync("DownloadTimer”);

The library generates a record that POSTs to the server: