Skip to content

ShowMessageAsync throws when cancelledย #3214

Closed

Description

@ian-g-holm-intel

Description

I am unable to cancel a dialog created using DialogCoordinator.Instance.ShowMessageAsync() without getting an exception with the message "The calling thread cannot access this object because a different thread owns it." I've tried with and without using Dispatcher.Invoke.

What steps will reproduce this issue?

  1. Create an instance of MetroDialogSettings with CancellationToken assigned
  2. Call ShowMessageAsync using the DialogCoordinator and passing in the dialog settings
  3. Cancel the token
  4. Exception is thrown

Expected outcome

Dialog should be closed without crashing the application and possibly throw OperationCanceledException on the invoking call stack (I don't really care whether the exception is thrown or not).

Repo

https://github.com/Retik/ShowMessageBugExample

Environment

  • MahApps.Metro: v1.6.1
  • Windows OS: Windows 10 Enterprise v1709
  • Visual Studio: 2017 Enterprise v15.6.4
  • .NET Framework: v4.6.1

Activity

  1. self-assigned this
    on Apr 4, 2018
  2. Erik-White commented on May 5, 2020

    @Erik-White

    I have the exact same issue, it is still present in the latest 2.x prerelease build
    It would be great if it could be fixed, very handy for easily closing a dialog on a timeout or when it's no longer relevant due to a task cancellation

  3. added this to the 2.4.2 milestone on Dec 4, 2020
  4. added a commit that references this issue on Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions