- PlayStation?Mobile Development Cookbook
- Michael Fleischauer
- 192字
- 2021-07-29 16:47:05
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 to true. Within our loop we poll SystemEvents.CheckEvents()
to see if any events have occurred. If an OnRestored
event occurs, our event handler will be fired.
Our event handler HandeSystemEventsOnRestored()
simply writes out a message to the console, then sets the _done
bool to true, causing our loop to end, and our program to exit.
Run this example, then minimize the simulator or change applications on your device. When you refocus the application, it will fire the OnRestored
event, causing your program to exit.
- 零點起飛學Xilinx FPG
- 電腦組裝、維護、維修全能一本通(全彩版)
- 硬件產品經理成長手記(全彩)
- Unity 5.x Game Development Blueprints
- 基于Apache Kylin構建大數據分析平臺
- Creating Flat Design Websites
- 深入理解序列化與反序列化
- LPC1100系列處理器原理及應用
- WebGL Hotshot
- Hands-On Motion Graphics with Adobe After Effects CC
- FPGA實驗實訓教程
- Building Machine Learning Systems with Python
- FPGA實戰訓練精粹
- 從企業級開發到云原生微服務:Spring Boot實戰
- 微服務架構實戰:基于Spring Boot、Spring Cloud、Docker