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) { SystemEvents.CheckEvents(); // 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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.