public void OnBackHandler(BackHandler handler) { switch (handler.Level) { default: case 0: break; case 1: case 3: Console.ForegroundColor = ConsoleColor.Yellow; break; case 2: Console.ForegroundColor = ConsoleColor.Red; break; } Console.WriteLine("{0} | {1} | {2} | {3}", handler.Level, handler.Message, handler.Exception, handler.State); Console.ForegroundColor = ConsoleColor.Gray; if (handler.Level == 2) { // 服务执行出错,进行补偿等工作 } else if (handler.Level == 3) { // 退出事件,清理你的业务 CleanUp(); } }
private void WebViewDone(string message) { BackHandler.Invoke(); }