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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
using System ;
using System.Collections.Generic ;
using System.Configuration ;
using System.Data ;
using System.Linq ;
using System.Threading.Tasks ;
using System.Windows ;
namespace STranslate
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
private static System . Threading . Mutex mutex ;
//系统能够识别有名称的互斥,因此可以使用它禁止应用程序启动两次
//第二个参数可以设置为产品的名称:Application.ProductName
// 每次启动应用程序, 都会验证名称为OnlyRun的互斥是否存在
protected override void OnStartup ( StartupEventArgs e )
{
mutex = new System . Threading . Mutex ( true , "CE252DD8-179F-4544-9989-453F5DEA378D" ) ;
if ( mutex . WaitOne ( 0 , false ) )
{
base . OnStartup ( e ) ;
}
else
{
MessageBox . Show ( "STranslate 已在运行..." , "提示" ) ;
this . Shutdown ( ) ;
}
}
}
}