Skip to content

Commit 8619b3f

Browse files
committed
virtual subscriblines and safe exit code checks
1 parent c51d5a2 commit 8619b3f

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"version": "2.0.3"
44
},
55
"versions": {
6-
"proc": "v0.1.3"
6+
"proc": "v0.1.4"
77
}
88
}

src/Proc/ObservableProcess.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ public IDisposable Subscribe(IObserver<LineOut> observer)
122122
return new CompositeDisposable(newlines, connected);
123123
}
124124

125-
public IDisposable SubscribeLines(Action<LineOut> onNext, Action<Exception> onError, Action onCompleted) =>
125+
public virtual IDisposable SubscribeLines(Action<LineOut> onNext, Action<Exception> onError, Action onCompleted) =>
126126
this.Subscribe(Observer.Create(onNext, onError, onCompleted));
127127

128-
public IDisposable SubscribeLines(Action<LineOut> onNext, Action<Exception> onError) =>
128+
public virtual IDisposable SubscribeLines(Action<LineOut> onNext, Action<Exception> onError) =>
129129
this.Subscribe(Observer.Create(onNext, onError, delegate { }));
130130

131-
public IDisposable SubscribeLines(Action<LineOut> onNext) =>
131+
public virtual IDisposable SubscribeLines(Action<LineOut> onNext) =>
132132
this.Subscribe(Observer.Create(onNext, delegate { }, delegate { }));
133133

134134
private void OnNextConsoleOut(CharactersOut c, IObserver<CharactersOut> observer)

src/Proc/ObservableProcessBase.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ protected void OnExit(IObserver<TConsoleOut> observer)
101101
{
102102
exitCode = this.Process.ExitCode;
103103
}
104+
//ExitCode and HasExited are all trigger happy. We are aware the process may or may not have an exit code.
105+
catch (InvalidOperationException) { }
104106
finally
105107
{
106108
ExitStop(observer, exitCode);
@@ -249,10 +251,7 @@ private void Stop(int? exitCode = null, IObserver<TConsoleOut> observer = null)
249251
//Access denied usually means the program is already terminating.
250252
catch (Win32Exception) { }
251253
//This usually indiciates the process is already terminated
252-
catch (InvalidOperationException)
253-
{
254-
}
255-
254+
catch (InvalidOperationException) { }
256255
try
257256
{
258257
this.Process?.Dispose();

0 commit comments

Comments
 (0)