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

Commit 27dcf50

Browse files
kyletran407Kyle Tranjfversluis
authored
The validationTokenSource should be set to null right after ValidateAsync is called. Otherwise, if the token is canceled (token.IsCancellationRequested is true) and therefore validationTokenSource is not set to null, next call to ResetValidationTokenSource will crash at line validationTokenSource?.Cancel() because validationTokenSource object is already disposed (see the using statement that creates the token). (#1694)
Co-authored-by: Kyle Tran <[email protected]> Co-authored-by: Gerald Versluis <[email protected]>
1 parent 5c2d689 commit 27dcf50

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/CommunityToolkit/Xamarin.CommunityToolkit/Behaviors/Validators/ValidationBehavior.shared.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,11 @@ async ValueTask UpdateStateAsync(bool isForced, CancellationToken? parentToken =
279279
try
280280
{
281281
var isValid = await ValidateAsync(Decorate(Value), token).ConfigureAwait(false);
282+
validationTokenSource = null;
282283

283284
if (token.IsCancellationRequested)
284285
return;
285286

286-
validationTokenSource = null;
287287
IsValid = isValid;
288288
IsRunning = false;
289289
}

0 commit comments

Comments
 (0)