是跨线程异常在Windows不太严格的7 [英] Are Cross-Thread exceptions less strict in Windows 7

查看:118
本文介绍了是跨线程异常在Windows不太严格的7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了使用的WinForms代码的BackgroundWorker 做一些异步工作,然后在完成时更新UI;我使用的是Windows 7中已经有少数情况下,我已经不小心,和子线程上访问UI组件。出于某种原因,这一直很好,但只破一旦有人在Windows XP上测试过别的。而奇怪的是,它也的当代码通过调试运行在Windows 7上休息的。

I've been writing WinForms code that uses a BackgroundWorker to do some async work, and then update the UI when done; I'm using Windows 7. There have been a few cases where I've been careless, and accessed UI components on the child thread. For some reason this has worked fine, but only broken once someone else tested on Windows XP. And oddly enough, it also breaks on Windows 7 when the code is run through the debugger.

有人可以帮助我了解什么是怎么回事 - 除了事实上,我是一个马虎,粗心的程序员:)

Can someone help me to understand what's going on here - other than the fact that I'm a sloppy, careless programmer :) ?

是跨线程异常在Windows 7不同的处理VIS-一个可见的Windows XP?

Are cross-thread exceptions handled differently on Windows 7 vis-a-vis Windows XP?

推荐答案

通常,这种操作的结果是不确定的。设置Control.CheckForIllegalCrossThreadCalls属性设置为True在节目开始时得到每跨线程调用预测失败。

Generally, result of such operation is undefined. Set Control.CheckForIllegalCrossThreadCalls Property to true in the beginning of the program to get predictable failure on every cross-thread call.

这篇关于是跨线程异常在Windows不太严格的7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆