Handling system events

This recipe covers handling the OnRestored system event.

Getting ready

The complete code for this example is available in Ch01_Example06.

How to do it...

Replace Main() with the following code:

public class AppMain
 static bool _done = false;
 public static void Main (string[] args){
  SystemEvents.OnRestored += HandleSystemEventsOnRestored;
  while(!_done)  {
   // Loop until application minimized then restored.

 static void HandleSystemEventsOnRestored (object sender, RestoredEventArgs e)
  Console.WriteLine ("System restored, ok to shut down");
  _done = true;

How it works...

This code starts by wiring an OnRestored event handler to global class SystemEvents. We then loop until the _done bool is set ...

Get PlayStation®Mobile Development Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.