wpf单例及带参数调用
程序员文章站
2022-07-13 22:23:28
...
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Windows;
namespace FM
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
Process process = Process.GetCurrentProcess();
foreach (Process p in Process.GetProcessesByName(process.ProcessName))
{
if (p.Id != process.Id)
{
MessageBox.Show("您的程序已经启动");
Application.Current.Shutdown();
return;
}
}
base.OnStartup(e);
if (e.Args.Length == 2)
{
Arg.ThisWbName = e.Args[0];
Arg.ThisShtName = e.Args[1];
}
//foreach (var item in e.Args)
//{
// MessageBox.Show(item);
//}
}
}
public class Arg
{
public static string ThisWbName { get; set; }
public static string ThisShtName { get; set; }
}
}
上一篇: [WPF]限制程序单例运行
下一篇: WPF MVVM模式下的无阻塞刷新探讨