Results 1 to 2 of 2

Thread: SerialPort and Control Updating in MDI form

Hybrid View

  1. #1
    New Member
    Join Date
    Aug 11
    Posts
    7

    SerialPort and Control Updating in MDI form

    Hello guys,

    As my title implies i have the following problem, i am receiving data from serial port and i update a richtextbox in a MDI Form with the control.invoke method

    (Code in SerialPort.DataReceived Event)
    Code:
    If myTerminal.Visible Then
                myTerminal.MyRichTextBox1.Invoke(New MethodInvoker(Sub()
                                                                       myTerminal.MyRichTextBox1.AppendText(dataLine & vbCrLf)
                                                                   End Sub))
            End If
    But as a mdi form it has the ability to close and reopen. So when the serialport is sending data to richtextbox and the user click the close button and the form gets disposed. Then the error "Invoke or BeginInvoke cannot be called on a control until the window handle has been created."... Any Idea????

    My regards,
    Ribben

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,766

    Re: SerialPort and Control Updating in MDI form

    So set that variable to Nothing when the form closes and then test the variable for Nothing before you use it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •