@@ -32,7 +32,8 @@ public sealed class SerialPort : IDisposable
3232
3333 private int _writeTimeout = Timeout . Infinite ;
3434 private int _readTimeout = Timeout . Infinite ;
35- private int _receivedBytesThreshold ;
35+ // default threshold is 1
36+ private int _receivedBytesThreshold = 1 ;
3637 private int _baudRate ;
3738 private Handshake _handshake = Handshake . None ;
3839 private StopBits _stopBits ;
@@ -429,6 +430,7 @@ public int WriteTimeout
429430 /// Gets or sets the number of bytes in the internal input buffer before a <see cref="DataReceived"/>
430431 /// event occurs.
431432 /// </summary>
433+ /// <value>The number of bytes in the internal input buffer before a <see cref="DataReceived"/> event is fired. The default is 1.</value>
432434 /// <exception cref="ArgumentOutOfRangeException">The <see cref="ReceivedBytesThreshold"/> value is less than or equal
433435 /// to zero.</exception>
434436 public int ReceivedBytesThreshold
@@ -437,12 +439,7 @@ public int ReceivedBytesThreshold
437439
438440 set
439441 {
440- if ( value <= 0 )
441- {
442- throw new ArgumentOutOfRangeException ( ) ;
443- }
444-
445- _receivedBytesThreshold = value ;
442+ NativeReceivedBytesThreshold ( value ) ;
446443 }
447444 }
448445
@@ -849,6 +846,9 @@ public void Dispose()
849846 [ MethodImpl ( MethodImplOptions . InternalCall ) ]
850847 internal static extern string GetDeviceSelector ( ) ;
851848
849+ [ MethodImpl ( MethodImplOptions . InternalCall ) ]
850+ internal extern void NativeReceivedBytesThreshold ( int value ) ;
851+
852852 #endregion
853853 }
854854}
0 commit comments