S
Sin Jeong-hun
I've using thread a lot in C#, but all of them were just single method
with no return value or paramenters. It may sound bizarre but, can't
it be a class?
I'm writing an Windows application that processes inputs from a serial
port. The serial port data is processed when DataReceived event occurs
from the SerialPort instance. If the DataReceived event handler and
the MainForm are in the same thread, and the user is calling a method
in the Mainform which possibly take a few seconds, and if data is
received at that time, I worry that event might not be handled. So I
want to run serial port handler class in a separate thread but all I
know is to run a method as a thread.
//A method that takes 5 seconds
void OnMenuClicked(object sender, EventArgs e)
{
//Now 00:00:00
doing some work.....
//Now 00:00:05
}
void SerialPort_DataReceved(....)
{
//If this happend at 00:00:02, would it be processed?
}
If running a class as a separate class is a stupid idea, what should I
do to ensure the DataReceived events be processed properly even if the
MainForm is busy?
Thank you very much.
with no return value or paramenters. It may sound bizarre but, can't
it be a class?
I'm writing an Windows application that processes inputs from a serial
port. The serial port data is processed when DataReceived event occurs
from the SerialPort instance. If the DataReceived event handler and
the MainForm are in the same thread, and the user is calling a method
in the Mainform which possibly take a few seconds, and if data is
received at that time, I worry that event might not be handled. So I
want to run serial port handler class in a separate thread but all I
know is to run a method as a thread.
//A method that takes 5 seconds
void OnMenuClicked(object sender, EventArgs e)
{
//Now 00:00:00
doing some work.....
//Now 00:00:05
}
void SerialPort_DataReceved(....)
{
//If this happend at 00:00:02, would it be processed?
}
If running a class as a separate class is a stupid idea, what should I
do to ensure the DataReceived events be processed properly even if the
MainForm is busy?
Thank you very much.