终端一体化运控平台
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

App.xaml.cs 2.6 KiB

2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using BeDesignerSCADA.Helper;
  2. using BeDesignerSCADA.View;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Configuration;
  6. using System.Data;
  7. using System.Diagnostics;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Runtime.InteropServices;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. namespace BPASmart.MenuLoad
  15. {
  16. /// <summary>
  17. /// Interaction logic for App.xaml
  18. /// </summary>
  19. public partial class App : Application
  20. {
  21. bool isShow = false;
  22. [DllImport("kernel32.dll")]
  23. private static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max);
  24. string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf";
  25. private void FlushMemory()
  26. {
  27. GC.Collect();
  28. GC.WaitForPendingFinalizers();
  29. if (Environment.OSVersion.Platform == PlatformID.Win32NT)
  30. SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
  31. }
  32. protected override void OnStartup(StartupEventArgs e)
  33. {
  34. base.OnStartup(e);
  35. RunWindows run = new RunWindows();
  36. _ = Task.Factory.StartNew(delegate
  37. {
  38. while (true)
  39. {
  40. try
  41. {
  42. if (!isShow)
  43. {
  44. this.Dispatcher.Invoke(() => {
  45. if (File.Exists(_path))
  46. {
  47. SystemHelperNew.GetInstance.CreateShortcutOnDesktop();
  48. SystemHelperNew.GetInstance.CreateShortcutOnDesktop("可视化配置工具");
  49. //SystemHelperNew.GetInstance.CreateDesktopShortcut();
  50. run.LoadingData(_path);
  51. run.Show();
  52. isShow = true;
  53. }
  54. else
  55. {
  56. MessageBox.Show("未布局应用程序!");
  57. System.Windows.Application.Current.Shutdown(0);
  58. }
  59. });
  60. }
  61. FlushMemory();
  62. Thread.Sleep(TimeSpan.FromSeconds((double)1000));
  63. }
  64. catch { }
  65. }
  66. });
  67. }
  68. }
  69. }