WPF程序,运行时,结束时,要运行的操作(自动保存,检查单程序)

 1  /// <summary>
 2     /// App.xaml 的交互逻辑
 3     /// </summary>
 4     public partial class App : Application
 5     {
 6         private void AppExit(object sender, ExitEventArgs e)
 7         {
 8             if (Context.Me != null)
 9             {
10                 Context.Me.State = 3;
11                 Context.PicaClient.UpdateUser(Context.Me);
12             }
13         }
14 
15         private void AppStartup(object sender, StartupEventArgs e)
16         {
17             Process[] List = Process.GetProcesses();
18             if (Process.GetProcessesByName("pica2").Length > 1)
19             {
20                 MessageBox.Show("程序已经登录,不能再次登录。");
21                 Application.Current.Shutdown();
22             }
23         }
24     }

 

posted @ 2013-09-18 15:41  三台  阅读(422)  评论(0编辑  收藏  举报