解决方案 »
- 急,急,急!求教数值分析里三次样条插值I型插值的csharp代码
- 紧急求助:devexpress(2.0) xtragridview 日期问题?
- winform 项目怎么编译成dll
- .NET FrameWork 3.5 访问 Oracle 数据库方法?
- SQL Server 2005 Express Edition 启用远程连接
- asp.net网页获许手机的IMEI码
- 请教.net配置环境的问题~!
- C#2.0大数据量下哪个对象查询比较快些List<>还是DataTable
- 不用datagrid如何显示数据库数据?
- 在c#里面怎么获得应用程序所在的路径?
- web使用ThreadPool,浏览器不需要等待而操作其他页面?
- 这种网页怎么做
{
timer.Stop();
if (Thread == null)
{
Thread = new System.Threading.Thread(DownloadInfo);
Thread.Start();
}
else
{
Thread.Abort();
Thread = new System.Threading.Thread(DownloadInfo);
Thread.Start();
}
}
private void DownloadInfo()
{
System.Threading.Thread.Sleep(10000);//相当于函数执行了十秒
timer.Start();//这次Start不能触发Tick
}
System.Timers.Timer timer;
public void TimeTest()
{
timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Start();
Console.ReadLine();
} void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Console.WriteLine("timer 停止啦");
Thread t = new Thread(new ThreadStart(() => { Thread.Sleep(1000); timer.Start(); Console.WriteLine("timer 启动啦"); }));
t.Start();
timer.Stop();
}
测试可以。
在你建的线程中使用this.Invoke(
(MethodInvoker)delegate
{
timer1.Start();
});
另外也可以在构造函数中写上
CheckForIllegalCrossThreadCalls=false;来取消线程安全检测