main()
{
thread_B.start();
thread_A.start();
}
public void Thread_A()
{
while(true)
if (State == 1)
{
try
{
Thread_B.Interrupt();
if (!thr.Join(5000))
{
Thread_B.Abort();
GC.Collect();
Thread_B.ExecutionContext.Dispose();
}
Console.WriteLine("\nInsert_Dongle");
}
catch (Exception e)
{ }
}
}
Thread Thread_B= new Thread(delegate()
{
State = TLoop();
});
public static int TLoop()
{
while(true)
return 1;
}
i am opening serial port in thread _B
if some one removes the serial cable when code is running incoming data stops but the serial port is still opened if i tried to close the serial port it gives
" unhandled exception system.ObjectDisposedException occured in mscorlib.dll addition information : Safe handle has been closed"
how to close the comport?