交叉调用 - .net 1.1 2.0 升级后许多控制重型 GUI 应用程序 - 最好的方法?

发布于 2024-08-26 05:49:00 字数 318 浏览 6 评论 0原文

我最近将 .net1.1 解决方案升级到 .net2.0。 因为这是一个非常繁重的 GUI 应用程序,具有大量控件和许多更新 GUI 的多线程操作。 虽然这些操作在 .net1.1 中无缝运行,但在升级后会引发跨线程非法操作。 考虑到有大量网格、按钮和状态标签需要通过这些多线程操作进行更新,我决定编写代码来检查 InvokeRequired 解决方案,但是为每个控件执行此操作可能不是最好的方法它。

我想知道您是否可以建议一种更好的方法来解决这个问题,或者提出任何基于 OOPS 的类结构,我可以对其进行编码以使代码看起来更好。

如果我的问题不清楚,请告诉我。

提前致谢

I have recently upgraded a .net1.1 solution to .net2.0.
AS this is a very heavy GUI appilcation with loads of controls and many multithreaded operations that update the GUI.
While these operations worked seamlessly in .net1.1 it is throwing up Cross Threaded Illegal operations after the upgrade.
Considering the fact that tehre are numerous grids, buttons and status labels that need to be updated via these multi threaded operations, I decided to code for checking the InvokeRequired solution, however doing that for every control would probably not be the best way to go about it.

I was wondering if you could suggest a better way of how I can go about it or propose any OOPS based class structure that I could code around to make the code look better.

Please do let me know if my question is unclear.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尝蛊 2024-09-02 05:49:00

这是一篇关于您的问题的好文章:

http://www.perceler.com/articles1。 php?art=crossthreads1

快速而肮脏的技巧是完全禁用检查:

static class Extensions {
   public static DisableCrossThreadCheck(this Control c){
    c.CheckForIllegalCrossThreadedCalls = false;
    foreach(var ctl in c.Controls) { 
      ctl.DisableCrossThreadCheck();
    }
   }
}

(in your form): 
this.DisableCrossThreadCheck();

Here's a good article about your problem:

http://www.perceler.com/articles1.php?art=crossthreads1

The quick and dirty hack is to disable the check altogether:

static class Extensions {
   public static DisableCrossThreadCheck(this Control c){
    c.CheckForIllegalCrossThreadedCalls = false;
    foreach(var ctl in c.Controls) { 
      ctl.DisableCrossThreadCheck();
    }
   }
}

(in your form): 
this.DisableCrossThreadCheck();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文