• <i id='KMxoI'><tr id='KMxoI'><dt id='KMxoI'><q id='KMxoI'><span id='KMxoI'><b id='KMxoI'><form id='KMxoI'><ins id='KMxoI'></ins><ul id='KMxoI'></ul><sub id='KMxoI'></sub></form><legend id='KMxoI'></legend><bdo id='KMxoI'><pre id='KMxoI'><center id='KMxoI'></center></pre></bdo></b><th id='KMxoI'></th></span></q></dt></tr></i><div id='KMxoI'><tfoot id='KMxoI'></tfoot><dl id='KMxoI'><fieldset id='KMxoI'></fieldset></dl></div>
    1. <small id='KMxoI'></small><noframes id='KMxoI'>

        <bdo id='KMxoI'></bdo><ul id='KMxoI'></ul>
      <tfoot id='KMxoI'></tfoot>

        <legend id='KMxoI'><style id='KMxoI'><dir id='KMxoI'><q id='KMxoI'></q></dir></style></legend>
      1. 使用“Control.CheckForIllegalCrossThreadCalls = false"是个好主

        时间:2023-09-15

              <tbody id='OjcP7'></tbody>
            <tfoot id='OjcP7'></tfoot>
              <i id='OjcP7'><tr id='OjcP7'><dt id='OjcP7'><q id='OjcP7'><span id='OjcP7'><b id='OjcP7'><form id='OjcP7'><ins id='OjcP7'></ins><ul id='OjcP7'></ul><sub id='OjcP7'></sub></form><legend id='OjcP7'></legend><bdo id='OjcP7'><pre id='OjcP7'><center id='OjcP7'></center></pre></bdo></b><th id='OjcP7'></th></span></q></dt></tr></i><div id='OjcP7'><tfoot id='OjcP7'></tfoot><dl id='OjcP7'><fieldset id='OjcP7'></fieldset></dl></div>

              <legend id='OjcP7'><style id='OjcP7'><dir id='OjcP7'><q id='OjcP7'></q></dir></style></legend>
              1. <small id='OjcP7'></small><noframes id='OjcP7'>

                  <bdo id='OjcP7'></bdo><ul id='OjcP7'></ul>
                  本文介绍了使用“Control.CheckForIllegalCrossThreadCalls = false"是个好主意吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个从串口接收数据的类.我用 action;委托 将数据传递给在文本框中显示的表单.问题是我无法访问 textbox 控件,因为它说:Cross-thread operation not valid: Control 从创建它的线程以外的线程访问.

                  I have a class that receives data from serialport. i used action<T> delegate to pass data to the form where it is displayed in a textbox. the thing is i could not access the textbox control, becouse it says: Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.

                  所以我设置了 Control.CheckForIllegalCrossThreadCalls = false,它正在工作.

                  so i set Control.CheckForIllegalCrossThreadCalls = false, and it is working.

                  这样做是个好主意吗?或者有更好的方法.

                  is it good idea to do that? or there is a better way of doing it.

                  谢谢

                  推荐答案

                  虽然它看起来大部分时间都可以工作,但它肯定会时不时地失败.

                  While it may appear to work most of the time, it is sure to fail every now and then.

                  如果您需要从另一个线程访问/修改 UI 控件,请使用 Control.Invoke.

                  If you need to access/modify the UI control from another thread, use Control.Invoke.

                  这篇关于使用“Control.CheckForIllegalCrossThreadCalls = false"是个好主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 C# 中将事件从一个表单传播到另一个表单 下一篇:C# 控制台应用程序 + 事件处理

                  相关文章

                • <i id='0KbPr'><tr id='0KbPr'><dt id='0KbPr'><q id='0KbPr'><span id='0KbPr'><b id='0KbPr'><form id='0KbPr'><ins id='0KbPr'></ins><ul id='0KbPr'></ul><sub id='0KbPr'></sub></form><legend id='0KbPr'></legend><bdo id='0KbPr'><pre id='0KbPr'><center id='0KbPr'></center></pre></bdo></b><th id='0KbPr'></th></span></q></dt></tr></i><div id='0KbPr'><tfoot id='0KbPr'></tfoot><dl id='0KbPr'><fieldset id='0KbPr'></fieldset></dl></div>
                  <tfoot id='0KbPr'></tfoot>

                  <small id='0KbPr'></small><noframes id='0KbPr'>

                      • <bdo id='0KbPr'></bdo><ul id='0KbPr'></ul>

                      <legend id='0KbPr'><style id='0KbPr'><dir id='0KbPr'><q id='0KbPr'></q></dir></style></legend>