Skip to content

Commit fda54c9

Browse files
Fixed long-running operations on SnackBarMessage callback (#2627) (#2631)
actionClickWaitHandle will be disposed after message auto-closed. We need to avoid call any methods on disposed EventWaitHandle, need to check is it closed (disposed) or invalid Co-authored-by: Andrey Nasonov <[email protected]>
1 parent f1e09c2 commit fda54c9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

MaterialDesignThemes.Wpf/SnackbarMessageQueue.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,11 @@ private static Tuple<SnackbarMessage, MouseNotOverManagedWaitHandle> CreateAndSh
384384
{
385385
if (++clickCount == 1)
386386
DoActionCallback(messageQueueItem);
387+
388+
// Don't operate with eventWaitHandle if disposed/invalid
389+
if (actionClickWaitHandle.SafeWaitHandle.IsInvalid || actionClickWaitHandle.SafeWaitHandle.IsClosed)
390+
return;
391+
387392
actionClickWaitHandle.Set();
388393
};
389394
snackbar.SetCurrentValue(Snackbar.MessageProperty, snackbarMessage);

0 commit comments

Comments
 (0)