Skip to content

Commit

Permalink
fix: isExecuting when .Execute throws exception (#3246)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomáš Filip <tomas.filip@meac.cz>
  • Loading branch information
tomasfil and Tomáš Filip authored Apr 30, 2022
1 parent 41a3ef5 commit 5af2e48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/ReactiveUI.Tests/Commands/ReactiveCommandTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -1157,7 +1157,8 @@ public async Task ReactiveCommandCreateFromTaskHandlesTaskExceptionAsync()
{
await subj.Take(1);
throw new Exception("break execution");
});
},
outputScheduler: ImmediateScheduler.Instance);

fixture.IsExecuting.Subscribe(x => isExecuting = x);
fixture.ThrownExceptions.Subscribe(ex => fail = ex);
Expand All @@ -1172,7 +1173,7 @@ public async Task ReactiveCommandCreateFromTaskHandlesTaskExceptionAsync()
subj.OnNext(Unit.Default);

// Wait 10 ms to allow execution to complete
await Task.Delay(10).ConfigureAwait(false);
await Task.Delay(500).ConfigureAwait(false);

Assert.False(isExecuting);
Assert.Equal("break execution", fail?.Message);
Expand Down
2 changes: 0 additions & 2 deletions src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,6 @@ public override IObservable<TResult> Execute(TParam parameter)
.Catch<TResult, Exception>(
ex =>
{
_synchronizedExecutionInfo.OnNext(ExecutionInfo.CreateEnd());
_exceptions.OnNext(ex);
return Observable.Throw<TResult>(ex);
}).Finally(() => _synchronizedExecutionInfo.OnNext(ExecutionInfo.CreateEnd()))
Expand Down Expand Up @@ -755,7 +754,6 @@ public override IObservable<TResult> Execute()
.Catch<TResult, Exception>(
ex =>
{
_synchronizedExecutionInfo.OnNext(ExecutionInfo.CreateEnd());
_exceptions.OnNext(ex);
return Observable.Throw<TResult>(ex);
}).Finally(() => _synchronizedExecutionInfo.OnNext(ExecutionInfo.CreateEnd()))
Expand Down

0 comments on commit 5af2e48

Please sign in to comment.