G
Guest
Hi,
I have the following problem. I created a
Properties section:
private SerialComm oComm = new SerialComm(); // Wraps a DLL to handle Serial
//comms.
private Thread PrinterThread = null; // Serial Communications Thread
private void Form_load(...)
{
PrinterThread = new Thread(new ThreadStart(StartPrinter));
PrinterThread.Name = "SerialPrinter";
}
// The Thread is started in this procedure
private void button_click(....)
{
if (PrinterThread.ThreadState.ToString() == "Unstarted")
{
try
{
PrinterThread.Start();
Thread.Sleep(0);
}
catch (Exception Ex)
{
//Handle exception
}
}
// This is the procedure the for the Thread
private void StartPrinter()
{
Thread.Sleep(0);
LogInfo("Label Printing: printing thread started");
oComm.sendToPrinter(sFactor,false);
// Calls the serial printing process. It starts its own receiving Thread
within it.
// Returns to this procedure when done. The receiving thread must have
been
//aborted.
if (oComm.lStatus)
this.sMessage.Text = "Printing label has Finished";
// I got an Thread exeption here. After the aborting the receiving
thread
// If this.sMessage.txt is not there, it doesn't happen. Why????
// The exception says: ThreadException found while thread is being
aborted.
// I think it refers to the receiving thread.
this.cmdLabel.Enabled = true;
this.cmdReprint.Enabled = true
}
Thank you,
Carlos
I have the following problem. I created a
Properties section:
private SerialComm oComm = new SerialComm(); // Wraps a DLL to handle Serial
//comms.
private Thread PrinterThread = null; // Serial Communications Thread
private void Form_load(...)
{
PrinterThread = new Thread(new ThreadStart(StartPrinter));
PrinterThread.Name = "SerialPrinter";
}
// The Thread is started in this procedure
private void button_click(....)
{
if (PrinterThread.ThreadState.ToString() == "Unstarted")
{
try
{
PrinterThread.Start();
Thread.Sleep(0);
}
catch (Exception Ex)
{
//Handle exception
}
}
// This is the procedure the for the Thread
private void StartPrinter()
{
Thread.Sleep(0);
LogInfo("Label Printing: printing thread started");
oComm.sendToPrinter(sFactor,false);
// Calls the serial printing process. It starts its own receiving Thread
within it.
// Returns to this procedure when done. The receiving thread must have
been
//aborted.
if (oComm.lStatus)
this.sMessage.Text = "Printing label has Finished";
// I got an Thread exeption here. After the aborting the receiving
thread
// If this.sMessage.txt is not there, it doesn't happen. Why????
// The exception says: ThreadException found while thread is being
aborted.
// I think it refers to the receiving thread.
this.cmdLabel.Enabled = true;
this.cmdReprint.Enabled = true
}
Thank you,
Carlos