Created
January 9, 2014 04:55
-
-
Save tuanpmt/8329583 to your computer and use it in GitHub Desktop.
HOW TO UPDATE UI FROM THREAD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Form1() | |
{ | |
InitializeComponent(); | |
serialPort1.PortName = "COM2"; | |
serialPort1.BaudRate = 9600; | |
serialPort1.Open(); | |
Thread oThread = new Thread(new ThreadStart(recvThread)); | |
oThread.Start(); | |
} | |
private void recvThread() | |
{ | |
while (true) | |
{ | |
byte b = (byte)serialPort1.ReadByte(); /* wait a byte from COM port */ | |
label1.Text = b.ToString(); /* error! */ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment