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

        C#:SerialPort.Open 超时?

        C#: Timeout on SerialPort.Open?(C#:SerialPort.Open 超时?)

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

        • <bdo id='AhQlg'></bdo><ul id='AhQlg'></ul>
            <tbody id='AhQlg'></tbody>
          <tfoot id='AhQlg'></tfoot>
        • <small id='AhQlg'></small><noframes id='AhQlg'>

              <legend id='AhQlg'><style id='AhQlg'><dir id='AhQlg'><q id='AhQlg'></q></dir></style></legend>

                  本文介绍了C#:SerialPort.Open 超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个自动检测线程尝试按顺序打开端口并匹配接收到的数据,从而检测相关设备发送数据的端口.现在,有一些端口 SerialPort.Open 只是将线程挂起约 30 秒.如何设置 SerialPort.Open 函数的超时时间?

                  I have an autodetect thread that tries to open the ports in order and match the received data, thus detecting the port where the relevant device sends the data. Now, there are some ports where the SerialPort.Open simply hangs the thread for ~30 secs. How can I set a timeout on the SerialPort.Open function?

                  推荐答案

                  来自 MSDN
                  每个 SerialPort 对象只能存在一个打开的连接.

                  From MSDN
                  Only one open connection can exist per SerialPort object.

                  任何应用程序的最佳做法是在调用 Close 方法后等待一段时间,然后再尝试调用 Open 方法,因为端口可能不会立即关闭.

                  The best practice for any application is to wait for some amount of time after calling the Close method before attempting to call the Open method, as the port may not be closed instantly.

                  当您调用 Close() 时,此工作线程需要时间来减速并退出.未指定所需的时间量,您无法验证它是否已完成.您所能做的就是在再次调用 Open() 之前等待至少一秒钟.

                  When you call Close(), this worker thread needs time to spin down and exit. The amount of time needed is not specified and you can't verify that it was done. All you can do is wait at least one second before you call Open() again.

                  这篇关于C#:SerialPort.Open 超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)

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

                    1. <tfoot id='RVnNP'></tfoot>

                            <tbody id='RVnNP'></tbody>
                          • <bdo id='RVnNP'></bdo><ul id='RVnNP'></ul>

                            <small id='RVnNP'></small><noframes id='RVnNP'>