Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 68fdbf7

Browse files
committed
Task success means it ran to completion and didn't fail (but if we catch an exception, it's not a success)
1 parent 51c1a08 commit 68fdbf7

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/GitHub.Api/Tasks/ProcessTask.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ class ProcessTask<T> : TaskBase<T>, IProcessTask<T>
213213
{
214214
private IOutputProcessor<T> outputProcessor;
215215
private ProcessWrapper wrapper;
216-
private bool finished = false;
217216

218217
public event Action<string> OnErrorData;
219218
public event Action<IProcess> OnStartProcess;
@@ -303,7 +302,6 @@ public override T RunWithReturn(bool success)
303302
RaiseOnStart,
304303
() =>
305304
{
306-
finished = true;
307305
try
308306
{
309307
if (outputProcessor != null)
@@ -352,7 +350,7 @@ public override string ToString()
352350

353351
public Process Process { get; set; }
354352
public int ProcessId { get { return Process.Id; } }
355-
public override bool Successful { get { return finished && ((!taskFailed && Process.ExitCode == 0) || (taskFailed && exceptionWasHandled)); } }
353+
public override bool Successful { get { return base.Successful && Process.ExitCode == 0; } }
356354
public StreamWriter StandardInput { get { return wrapper?.Input; } }
357355
public virtual string ProcessName { get; protected set; }
358356
public virtual string ProcessArguments { get; }
@@ -486,7 +484,7 @@ public override string ToString()
486484

487485
public Process Process { get; set; }
488486
public int ProcessId { get { return Process.Id; } }
489-
public override bool Successful { get { return Task.Status == TaskStatus.RanToCompletion && Process.ExitCode == 0; } }
487+
public override bool Successful { get { return base.Successful && Process.ExitCode == 0; } }
490488
public StreamWriter StandardInput { get { return wrapper?.Input; } }
491489
public virtual string ProcessName { get; protected set; }
492490
public virtual string ProcessArguments { get; }

src/GitHub.Api/Tasks/TaskBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,10 @@ public override string ToString()
491491
return $"{Task?.Id ?? -1} {Name} {GetType()}";
492492
}
493493

494-
public virtual bool Successful { get { return !taskFailed || exceptionWasHandled; } }
494+
public virtual bool Successful { get { return hasRun && !taskFailed; } }
495+
public bool IsCompleted { get { return hasRun; } }
495496
public string Errors { get; protected set; }
496497
public Task Task { get; protected set; }
497-
public bool IsCompleted { get { return hasRun; /*(Task as IAsyncResult).IsCompleted;*/ } }
498498
public WaitHandle AsyncWaitHandle { get { return (Task as IAsyncResult).AsyncWaitHandle; } }
499499
public object AsyncState { get { return (Task as IAsyncResult).AsyncState; } }
500500
public bool CompletedSynchronously { get { return (Task as IAsyncResult).CompletedSynchronously; } }

0 commit comments

Comments
 (0)