WPF外包公司—技术分享WPF只运行一个实例
首先 引用Microsoft.VisualBasic 然后新建一个类 single public class single:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase { App a; public single() { this.IsSingleInstance = true; } protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs eventArgs) { a = new App(); a.InitializeComponent(); a.Run(); return false; } protected override void OnStartupNextInstance(Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs eventArgs) { base.OnStartupNextInstance(eventArgs); a.activate(); } } app.cs public partial class App : Application {