Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Read data from a SerialPort: cross-thread not true

Read data from a SerialPort: cross-thread not true

Scheduled Pinned Locked Moved C#
helpcomtutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlexB47
    wrote on last edited by
    #1

    Hi All, I have a problem with a serialport component ... In a form, for read from a serial port I write: Load { serialPort1.Close(); serialPort1.NewLine = "\r\n"; serialPort1.PortName = "COM18"; // GPS COM serialPort1.Open(); } in the dataReceived event, the app stopped with this error: cross-thread not true... private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { textBox1.Text = serialPort1.ReadLine(); //error line } Why error on thread-safe? Help me please (with example). Many thanks.

    Alex

    L L 2 Replies Last reply
    0
    • A AlexB47

      Hi All, I have a problem with a serialport component ... In a form, for read from a serial port I write: Load { serialPort1.Close(); serialPort1.NewLine = "\r\n"; serialPort1.PortName = "COM18"; // GPS COM serialPort1.Open(); } in the dataReceived event, the app stopped with this error: cross-thread not true... private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { textBox1.Text = serialPort1.ReadLine(); //error line } Why error on thread-safe? Help me please (with example). Many thanks.

      Alex

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      http://www.developerfusion.com/forum/thread/43081/[^]

      A 1 Reply Last reply
      0
      • L Lost User

        http://www.developerfusion.com/forum/thread/43081/[^]

        A Offline
        A Offline
        AlexB47
        wrote on last edited by
        #3

        Perfect! Thanks. ;)

        Alex

        1 Reply Last reply
        0
        • A AlexB47

          Hi All, I have a problem with a serialport component ... In a form, for read from a serial port I write: Load { serialPort1.Close(); serialPort1.NewLine = "\r\n"; serialPort1.PortName = "COM18"; // GPS COM serialPort1.Open(); } in the dataReceived event, the app stopped with this error: cross-thread not true... private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { textBox1.Text = serialPort1.ReadLine(); //error line } Why error on thread-safe? Help me please (with example). Many thanks.

          Alex

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, I have two articles that seem relevant: asyncpool1[^] crossthreads1[^] :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          Happy New Year to all.
          We hope 2010 soon brings us automatic PRE tags!
          Until then, please insert them manually.


          A 1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, I have two articles that seem relevant: asyncpool1[^] crossthreads1[^] :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            Happy New Year to all.
            We hope 2010 soon brings us automatic PRE tags!
            Until then, please insert them manually.


            A Offline
            A Offline
            AlexB47
            wrote on last edited by
            #5

            thanks Luc ... rich documentations ... :)

            Alex

            L 1 Reply Last reply
            0
            • A AlexB47

              thanks Luc ... rich documentations ... :)

              Alex

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              you're welcome. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


              Happy New Year to all.
              We hope 2010 soon brings us automatic PRE tags!
              Until then, please insert them manually.


              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups