//在form中
static int num = 0;
private void button4_Click(object sender, EventArgs e)
{
this.process.Visible = true;
System.Threading.Timer t = new System.Threading.Timer(new TimerCallback(scan),
null, 0, 2000);
}
private void scan(object state)
{
num++;
MessageBox.Show(num.ToString());
}//在Console控制台中
class Program
{
static int num = 0;
static void Main()
{
Timer timer = new Timer(new TimerCallback(CheckStatus), null, 0,
2000);
Console.ReadLine();
} static void CheckStatus(object state)
{
num++;
Console.WriteLine(num.ToString ());
}
}
---------------------------------------------------------
上面在form环境的代码,怎么只执行8-10次的对话框就停止了,而在console中则没有问题?请大家分析
分析,谢谢! 我的联系方式:[email protected]
static int num = 0;
private void button4_Click(object sender, EventArgs e)
{
this.process.Visible = true;
System.Threading.Timer t = new System.Threading.Timer(new TimerCallback(scan),
null, 0, 2000);
}
private void scan(object state)
{
num++;
MessageBox.Show(num.ToString());
}//在Console控制台中
class Program
{
static int num = 0;
static void Main()
{
Timer timer = new Timer(new TimerCallback(CheckStatus), null, 0,
2000);
Console.ReadLine();
} static void CheckStatus(object state)
{
num++;
Console.WriteLine(num.ToString ());
}
}
---------------------------------------------------------
上面在form环境的代码,怎么只执行8-10次的对话框就停止了,而在console中则没有问题?请大家分析
分析,谢谢! 我的联系方式:[email protected]
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货