I'm working on simple chat program via serial port. It works fine, but i face this problem.
When i try to open the exe, UnauthorizedAcc ess exception occurs, i can't use COM1 becuase someone else has it. I checked it and found that another copy of the program still work (by task manager). That's mean closing the program will not close the serial port. I tried these :
Note: I read it using a separate thread.
1)override OnClose to, close the serial port.
But this evaluates an exception, where the thread is accessing the port and i terminate it.
2)override OnClose to, abort the thread then close the port.
A message that information cloud be lost appears.
3)override OnClose to, suspend the thread then close the port.
exception occurs just like (1).
I don't want to open the port and close it evey time i read or write, it'll be very ugly.
When i try to open the exe, UnauthorizedAcc ess exception occurs, i can't use COM1 becuase someone else has it. I checked it and found that another copy of the program still work (by task manager). That's mean closing the program will not close the serial port. I tried these :
Note: I read it using a separate thread.
1)override OnClose to, close the serial port.
But this evaluates an exception, where the thread is accessing the port and i terminate it.
2)override OnClose to, abort the thread then close the port.
A message that information cloud be lost appears.
3)override OnClose to, suspend the thread then close the port.
exception occurs just like (1).
I don't want to open the port and close it evey time i read or write, it'll be very ugly.
Comment