In the Microsoft .NET documentation for SerialPort.Close, the following cryptic statement is found.
"The best practice for any application is to wait for some amount of time after calling the Close method before attempting to call the Open method, as the port may not be closed instantly."
How many milliseconds in a "some amount of time" unit Our company has a library of Common Service classes that are used by a number of different development teams. One of those services provides for serial communications using the .NET 2.0 SerialPort class. At least one of our applications has a need for communicating with serial devices that may be using one of several different baud rates. To handle this, a negotiation process is used in which the serial port is opened with the highest expected baud rate. If the connection fails, the port is closed and re-opened with the next lowest expected baud rate, and so on until a valid connection is made (or the list of expected baud rates is exhausted).
After closing a port and re-opening it, we sometimes encounter an "UnauthorizedAccessException", generally indicating the port was not yet fully "closed" before we tried to re-open it. We can handle this by issuing a Sleep between the calls to Close and Open, but for performance reasons, we need to know the optimum (minimum) amount of time to "sleep". Other than the trial-and-error approach of experimenting with different amounts of time (and then verifying that the timeout is compatible with each of the applications from the development groups using the Common Services), is there a recommended timeout, or even better, some way of determining when it is safe to re-open the port

SerialPort - How much time between Close and Open?
Alcor38370