您的位置:首页 > 移动开发 > 微信开发

为什么用单例模式?微信就是用的单例模式

2015-06-12 22:04 579 查看
namespace Test
{     /// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{         public App()             : base()
{             Startup += new StartupEventHandler(App_Startup);
}
private void App_Startup(object sender, StartupEventArgs e)
{             int times = 0;
bool isRun = false;
while (times < 5)
{
System.Diagnostics.Process[] tmp = System.Diagnostics.Process.GetProcessesByName("你的应用程序的进程名称");
if (tmp.Length > 1)
{                     System.Threading.Thread.Sleep(1000);
isRun = true;
times++;                 }
else                 {
isRun = false;
break;                 }
}
if (isRun)
{
this.Shutdown();
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: