I have the following problem on a Windows 7 using VB.net with .NET Framework 4.0.
I have to send via a serial port a buffer of byte. The PC act like master and a device connected as slave receive the buffer. Each byte must be spaced from its next by a certain amount of time expressed in microseconds.

This is my code snippet

```
                        Dim t1 As New Stopwatch
                        Dim WatchTotal As New Stopwatch

                        WatchTotal.Reset()
                        WatchTotal.Start()

                        t1.Stop()
                        For i As Integer = 0 To _buffer.Length - 1

                            SerialPort1.Write(_buffer, i, 1)

                            t1.Reset()
                            t1.Start()

                            While ((1000000000 * t1.ElapsedTicks / Stopwatch.Frequency) < 50000) ' wait 50us
                            End While
                            t1.Stop()
                        Next

                        WatchTotal.Stop()

                        Debug.Print(WatchTotal.ElapsedMilliseconds)

```

Everything loop inside a thread.

Everything works correctly but on a machine with Windows 7 the Serial.write of 1 byte takes 1ms so if we have to send 1024 bytes it takes 1024ms. 

This is confirmed by printing the elapsed time 

```
Debug.Print(WatchTotal.ElapsedMilliseconds)

```

The problem seems to be in SerialPort.Write method.
The same code on a machine with Windows 10 takes less than 1ms. 

The problem is more visible when we have to send many buffers of byte, in this case we send 16 buffers of 1027 bytes. On Win 7 it takes less than 20 seconds, in Win10 it takes the half or less (to send 1 buffers of 1027 bytes it takes approximately 120-150ms and less than 5 seconds to send 16 buffers of data).

Does anyone have any idea what that might depend on?

Thanks 

---

EDIT 22/05/2020
---------------

If i remove the debug printing and the little delay to pause the communication i always have about 1027ms for sending 1027 bytes so i think that the problem belong only to SerialPort method and not to the timing or stopwatch object. This happen on a Windows 7 machine. The same executable on a Windows 10 machine go fast as expected.

```
                        For i As Integer = 0 To _buffer.Length - 1
                            SerialPort1.Write(_buffer, i, 1)
                        Next

```