由于线程退出或应用程序请求,i / o操作已中止。串行 [英] the i/o operation has been aborted because of either a thread exit or an application request. serial

查看:2595
本文介绍了由于线程退出或应用程序请求,i / o操作已中止。串行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub SerialPort1_DataReceived(sender As Object, e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived

        Dim bytRxBuff(CurrentUserRqst.iRcvLength) As Byte


        Dim iRcvdLength As Integer = SerialPort1.Read(bytRxBuff, 0, CurrentUserRqst.iRcvLength)

        SerialPort1.DiscardInBuffer()
        SerialPort1.DiscardOutBuffer()


        'Debug.EvaluateStatement(iRcvdLength)

        'Cls_Error.WriteToErrorLog(iRcvdLength.ToString, iRcvdLength.ToString, "Error")

        ProcessFrame(bytRxBuff, iRcvdLength)

    End Sub

    Private Sub Send_Frame(ByVal bytFrame As Byte(), ByVal iRcvLength As Integer)
   

 
            If bytFrame(1) = &HC Then
                SerialPort1.ReceivedBytesThreshold = 7
            Else
                SerialPort1.ReceivedBytesThreshold = iRcvLength
            End If


         
            If SerialPort1.IsOpen Then
                SerialPort1.Write(bytFrame, 0, bytFrame.Length)
            End If


            System.Threading.Thread.Sleep(100)

      
    End Sub


    Private Sub LatestDownload_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed


        If SerialPort1.IsOpen Then
            'SerialPort1.DataReceived -= Receive
            SerialPort1.DiscardInBuffer()
            SerialPort1.DiscardOutBuffer()
            SerialPort1.Close()
        End If

    End Sub







我关闭表格的地方会给出错误



由于线程退出或应用程序请求,i / o操作已中止。 serial




Where i close my form den it will give an error

the i/o operation has been aborted because of either a thread exit or an application request. serial

推荐答案

如果您只是用Google搜索您收到的错误消息,您会发现这是SerialPort类中的一个已知错误。



您还可以找到此博文 [< a href =http://zachsaw.blogspot.com/2010/07/net-serialport-woes.htmltarget =_ blanktitle =新窗口> ^ ]关于它为何出现问题如何绕过它。
Had you simply Googled the error message you got you would have found that this is a known bug in the SerialPort class.

You also would have found this blog post[^] about why it's a problem and how to get around it.


这篇关于由于线程退出或应用程序请求,i / o操作已中止。串行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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