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

Commit 6d17c4b

Browse files
committed
Fix setting busy flag when tasks are done
1 parent 447fd9c commit 6d17c4b

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

src/GitHub.Api/Tasks/ProcessTask.cs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ public void Run()
101101

102102
try
103103
{
104+
if (!Process.StartInfo.Arguments.StartsWith("credential-"))
105+
Logger.Trace($"Running '{Process.StartInfo.FileName} {Process.StartInfo.Arguments}'");
104106
Process.Start();
105107
}
106108
catch (Win32Exception ex)
@@ -286,20 +288,29 @@ protected override T RunWithReturn(bool success)
286288
RaiseOnStart,
287289
() =>
288290
{
289-
if (outputProcessor != null)
290-
result = outputProcessor.Result;
291+
try
292+
{
293+
if (outputProcessor != null)
294+
result = outputProcessor.Result;
291295

292-
if (result == null && !Process.StartInfo.CreateNoWindow && typeof(T) == typeof(string))
293-
result = (T)(object)"Process running";
296+
if (result == null && !Process.StartInfo.CreateNoWindow && typeof(T) == typeof(string))
297+
result = (T)(object)"Process running";
294298

295-
RaiseOnEnd(result);
296-
297-
if (Errors != null)
298-
{
299-
OnErrorData?.Invoke(Errors);
300-
thrownException = thrownException ?? new ProcessException(this);
301-
if (!RaiseFaultHandlers(thrownException))
299+
if (Errors != null)
300+
{
301+
OnErrorData?.Invoke(Errors);
302+
thrownException = thrownException ?? new ProcessException(this);
302303
throw thrownException;
304+
}
305+
}
306+
catch (Exception ex)
307+
{
308+
if (!RaiseFaultHandlers(ex))
309+
throw ex;
310+
}
311+
finally
312+
{
313+
RaiseOnEnd(result);
303314
}
304315
},
305316
(ex, error) =>

src/GitHub.Api/Tasks/TaskBase.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,24 +387,24 @@ protected virtual void RaiseOnEnd()
387387
OnEnd?.Invoke(this, !taskFailed, exception);
388388
if (!taskFailed || exceptionWasHandled)
389389
{
390-
if (continuationOnSuccess == null && continuationOnAlways == null)
390+
if (continuationOnSuccess == null)
391391
CallFinallyHandler();
392-
else if (continuationOnSuccess != null)
392+
else
393393
SetContinuation(continuationOnSuccess, runOnSuccessOptions);
394394
}
395395
else
396396
{
397-
if (continuationOnFailure == null && continuationOnAlways == null)
397+
if (continuationOnFailure == null)
398398
CallFinallyHandler();
399-
else if (continuationOnFailure != null)
399+
else
400400
SetContinuation(continuationOnFailure, runOnSuccessOptions);
401401
}
402402
//Logger.Trace($"Finished {ToString()}");
403403
}
404404

405405
protected void CallFinallyHandler()
406406
{
407-
finallyHandler?.Invoke(Task.Status == TaskStatus.RanToCompletion);
407+
finallyHandler?.Invoke(!taskFailed);
408408
}
409409

410410
protected virtual bool RaiseFaultHandlers(Exception ex)
@@ -617,9 +617,9 @@ protected virtual void RaiseOnEnd(TResult data)
617617
{
618618
this.result = data;
619619
OnEnd?.Invoke(this, result, !taskFailed, exception);
620-
if (continuationOnSuccess == null && continuationOnFailure == null && continuationOnAlways == null)
620+
if (continuationOnSuccess == null && continuationOnFailure == null)
621621
{
622-
finallyHandler?.Invoke(Task.Status == TaskStatus.RanToCompletion, result);
622+
finallyHandler?.Invoke(!taskFailed, result);
623623
CallFinallyHandler();
624624
}
625625
else if (continuationOnSuccess != null)

0 commit comments

Comments
 (0)