Skip to content

Commit

Permalink
Add optional pollInterval to portname polling function (#2)
Browse files Browse the repository at this point in the history
* Update SerialPortRx.cs

* Update SerialPortRx.cs

Enhance the port name change polling to be configurable and NOT be hard coded in the code.
  • Loading branch information
professordave authored and ChrisPulman committed Jan 7, 2019
1 parent bbf72f1 commit afe0a90
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SerialPortRx/SerialPortRx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ public SerialPortRx()
/// Gets the port names.
/// </summary>
/// <value>The port names.</value>
public static IObservable<string[]> PortNames => Observable.Create<string[]>(obs => {
public static IObservable<string[]> PortNames (int pollInterval = 500) => Observable.Create<string[]>(obs => {
string[] compare = null;
return Observable.Interval(TimeSpan.FromMilliseconds(500)).Subscribe(_ => {
return Observable.Interval(TimeSpan.FromMilliseconds(pollInterval)).Subscribe(_ => {
var compareNew = SerialPort.GetPortNames();
if (compareNew.Length == 0) {
compareNew = new string[] { "NoPorts" };
Expand Down

0 comments on commit afe0a90

Please sign in to comment.