using BeDesignerSCADA.Helper; using BeDesignerSCADA.View; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using System.Windows; namespace BPASmart.MenuLoad { /// /// Interaction logic for App.xaml /// public partial class App : Application { bool isShow = false; [DllImport("kernel32.dll")] private static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max); string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf"; private void FlushMemory() { GC.Collect(); GC.WaitForPendingFinalizers(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); } protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); RunWindows run = new RunWindows(); _ = Task.Factory.StartNew(delegate { while (true) { try { if (!isShow) { this.Dispatcher.Invoke(() => { if (File.Exists(_path)) { SystemHelperNew.GetInstance.CreateShortcutOnDesktop(); SystemHelperNew.GetInstance.CreateShortcutOnDesktop("可视化配置工具"); //SystemHelperNew.GetInstance.CreateDesktopShortcut(); run.LoadingData(_path); run.Show(); isShow = true; } else { MessageBox.Show("未布局应用程序!"); System.Windows.Application.Current.Shutdown(0); } }); } FlushMemory(); Thread.Sleep(TimeSpan.FromSeconds((double)1000)); } catch { } } }); } } }