码迷,mamicode.com
首页 > 微信 > 详细

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

时间:2015-06-12 23:45:04      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

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();
}
}
}
}

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

标签:

原文地址:http://www.cnblogs.com/hsha/p/4572693.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!