public partial class App : Application
{
private System.Threading.Mutex mutex;

public App()
{
this.Startup += new StartupEventHandler(App_Startup);
}

private void App_Startup(object sender, StartupEventArgs e)
{
bool ret;
mutex = new System.Threading.Mutex(true, "name", out ret);

if (!ret)
{
MessageBox.Show("程序已打开", "", MessageBoxButton.OK, MessageBoxImage.Stop);
Environment.Exit(0);
}
}
}

posted on 2014-01-03 11:40  CherryZhao  阅读(530)  评论(0编辑  收藏  举报