星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using Common.system;
  2. using System;
  3. using System.Diagnostics;
  4. using System.Threading;
  5. using System.Windows;
  6. using System.Windows.Threading;
  7. using XHWK.Model;
  8. namespace XHWK.WKTool
  9. {
  10. public partial class APP : Application
  11. {
  12. #region 全局变量
  13. /// <summary>
  14. /// 微课模型
  15. /// </summary>
  16. public static Model_WKData WKData = null;
  17. /// <summary>
  18. /// 讲解名称
  19. /// </summary>
  20. public static string WkName = null;
  21. /// <summary>
  22. /// 微课保存路径
  23. /// </summary>
  24. public static string WkSavePath = null;
  25. /// <summary>
  26. /// 主页面
  27. /// </summary>
  28. public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
  29. /// <summary>
  30. /// 开始录像
  31. /// </summary>
  32. public static CountdownWindow W_CountdownWindow = null;
  33. /// <summary>
  34. /// 录像工具栏
  35. /// </summary>
  36. public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
  37. #endregion
  38. [STAThread]
  39. private static void Main()
  40. {
  41. // 定义Application对象作为整个应用程序入口
  42. Application app = new Application();
  43. //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
  44. CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
  45. app.Run(win);
  46. //LogHelper.WriteInfoLog("启动项目");
  47. StopSameProcess();
  48. }
  49. private static void StopSameProcess()
  50. {
  51. Process current = Process.GetCurrentProcess();
  52. Process[] processList = Process.GetProcesses();
  53. foreach (Process process in processList)
  54. {
  55. if (process.ProcessName.ToUpper() == "XHSCHOOL")
  56. {
  57. if (process.Id != current.Id) //忽略当前进程
  58. {
  59. try
  60. {
  61. process.Kill(); //结束进程
  62. }
  63. catch (Exception)
  64. {
  65. }
  66. }
  67. }
  68. }
  69. }
  70. private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
  71. {
  72. LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
  73. MessageBox.Show("程序异常." + Environment.NewLine + e.Exception.Message);
  74. e.Handled = true;
  75. }
  76. #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  77. /// <summary>
  78. /// 内存释放压缩
  79. /// </summary>
  80. /// <param name="e"></param>
  81. protected override void OnStartup(StartupEventArgs e)
  82. {
  83. //private LierdaCracker cracker = new LierdaCracker();
  84. //cracker.Cracker(5000);//间隔时间
  85. //base.OnStartup(e);
  86. new Thread(o =>
  87. {
  88. while (true)
  89. {
  90. try
  91. {
  92. //FreeMemoryHelper.SetDate();
  93. FreeMemoryHelper.ReallocateMemory();
  94. Thread.Sleep(20000);//暂定每20秒释放一次
  95. }
  96. catch (Exception ex)
  97. {
  98. LogHelper.WriteErrLog("【释放内存(MyApp)" + ex.Message, ex);
  99. }
  100. }
  101. }).Start();
  102. }
  103. #endregion 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  104. }
  105. }