123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using Common.system;
-
- using System;
- using System.Diagnostics;
- using System.Threading;
- using System.Windows;
- using System.Windows.Threading;
-
- using XHWK.Model;
-
- namespace XHWK.WKTool
- {
- public partial class APP : Application
- {
- #region 全局变量
- /// <summary>
- /// 微课模型
- /// </summary>
- public static Model_WKData WKData = null;
- /// <summary>
- /// 讲解名称
- /// </summary>
- public static string WkName = null;
- /// <summary>
- /// 微课保存路径
- /// </summary>
- public static string WkSavePath = null;
- /// <summary>
- /// 主页面
- /// </summary>
- public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
- /// <summary>
- /// 开始录像
- /// </summary>
- public static CountdownWindow W_CountdownWindow = null;
- /// <summary>
- /// 录像工具栏
- /// </summary>
- public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
- #endregion
-
- [STAThread]
- private static void Main()
- {
- // 定义Application对象作为整个应用程序入口
- Application app = new Application();
- //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
- CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
- app.Run(win);
- //LogHelper.WriteInfoLog("启动项目");
- StopSameProcess();
- }
-
- private static void StopSameProcess()
- {
- Process current = Process.GetCurrentProcess();
- Process[] processList = Process.GetProcesses();
- foreach (Process process in processList)
- {
- if (process.ProcessName.ToUpper() == "XHSCHOOL")
- {
- if (process.Id != current.Id) //忽略当前进程
- {
- try
- {
- process.Kill(); //结束进程
- }
- catch (Exception)
- {
- }
- }
- }
- }
- }
-
- private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
- {
- LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
- MessageBox.Show("程序异常." + Environment.NewLine + e.Exception.Message);
- e.Handled = true;
- }
-
- #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
-
- /// <summary>
- /// 内存释放压缩
- /// </summary>
- /// <param name="e"></param>
- protected override void OnStartup(StartupEventArgs e)
- {
- //private LierdaCracker cracker = new LierdaCracker();
- //cracker.Cracker(5000);//间隔时间
- //base.OnStartup(e);
- new Thread(o =>
- {
- while (true)
- {
- try
- {
- //FreeMemoryHelper.SetDate();
- FreeMemoryHelper.ReallocateMemory();
- Thread.Sleep(20000);//暂定每20秒释放一次
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【释放内存(MyApp)" + ex.Message, ex);
- }
- }
- }).Start();
- }
-
- #endregion 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
- }
- }
|