解决方案 »
- ArrayList 和 imageList的使用的问题。
- 请问怎么动态获得web services中的类名和方法名?
- 数据类型 Money 是哪个命名空间的?
- [请教][难度问题]按钮事件中有循环的问题,用另一个按钮控制停止,暂停,继续
- 大家来看看这种东西怎么实现(GDI+的问题)
- C#的插件式程序是怎么实现的?有没有人给个基本思路?谢谢
- 请问在C#能不能做到?
- FolderBrowserDialog怎么屏蔽鼠标右键?
- 求一套比较好的在线订购系统(ASP)
- 我原来是学vb,现在想转向.net.但在vb.net与c#的取舍上出现了徘徊.请问二者到底有何区别,各善长??
- 第一次写windows服务,哪里错了啊?
- string remove()不起作用
http://msdn.microsoft.com/zh-cn/library/system.windows.threading.dispatcher(v=vs.110).aspx
http://msdn.microsoft.com/zh-cn/library/system.windows.threading.dispatchertimer(v=vs.110).aspx
例如下面的例子,如果我一次性操作了大量的控件有应该怎么写呢? this.txtNote.Dispatcher.Invoke(new Action(() =>
{
this.txtNote.Text += notes;
this.txtNote.Text += "\r";
this.txtNote.ScrollToEnd();
}));
例如下面的例子,如果我一次性操作了大量的控件有应该怎么写呢? this.txtNote.Dispatcher.Invoke(new Action(() =>
{
this.txtNote.Text += notes;
this.txtNote.Text += "\r";
this.txtNote.ScrollToEnd();
}));
操作大量控件,不需要指定某个控件的dispatcher,可以指定当前的/// <summary>
/// 当前线程调度器
/// </summary>
private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;可以使用_dispatcher.Invoke来操作控件。
{
timer4Check();
}));可是在抛出异常的时候却卡死了好几秒,请问应该怎样修改呢?
???不是很明白,为什么timer给停止了会使界面卡死呢?
???不是很明白,为什么timer给停止了会使界面卡死呢?
都抛出异常 ,你的timer 还在运行,你不觉得不合理吗?
???不是很明白,为什么timer给停止了会使界面卡死呢?
都抛出异常 ,你的timer 还在运行,你不觉得不合理吗?
于是我参考了http://blog.csdn.net/yl2isoft/article/details/11711833我把代码改下面这样了,不抛出错误照样卡死啊。 private void timer4Check()
{
string sb = GetHtmlValue(Convert.ToString(ConfigurationManager.AppSettings.Get("serverCheck"))).ToLowerInvariant() ;
_dispatcher.BeginInvoke(new Action(() =>
{
if (sb == "ok")
{
resetTimer4();
timer2.Stop();
timer3.Stop();
}
else
{
isDisableAll = true;
LinkError();
}
}));
}
还卡死么??
卡啊,请问_dispatcher.BeginInvoke-》timer4.Dispatcher.BeginInvoke是什么意思啊?