I have a C# program that communicates with serial devices using the built in SeralPort class. However, I want to do asynchronous writes and for that I am using BaseStream.BeginWrite(). In the async callback I call BaseStream.EndWrite(). All this works fine. However, on occasion I want to close a port BEFORE the BeginWrite() has finished but calling Close() causes it to hang as long as BeginWrite() is pending. I have tried calling EndWrite() but that also hangs if BeginWrite() is pending. How do I kill the BeginWrite() thread? There appears to be no BaseStream.Abort() or similar.
Thanks