Skip to content

ShowMessageAsync won't return any thing when using HideMetroDialogAsync while it's opened #2018

@bigworld12

Description

@bigworld12

how to produce :
create a timer with 5 seconds interval or what ever but don't start it
in the timer call back add this code

dial = DialogManager.GetCurrentDialogAsync<MessageDialog>(this).Result;
this.HideMetroDialogAsync(dial);

now in the main code start the timer first then call ShowMessageAsync
you will see that it will never return a value and the method calling it will never end
i think there is an easy solution by adding a "None" value to the MessageDialogResult Enum
and changing
this line : https://github.com/MahApps/MahApps.Metro/blob/master/MahApps.Metro/Controls/Dialogs/MessageDialog.cs#L45

to this :

public TaskCompletionSource<MessageDialogResult> tcs = new TaskCompletionSource<MessageDialogResult>();

then when calling HideMetroDialogAsync
you can do

 dial.cleanUpHandlers();
 dial.tcs.TrySetResult(MessageDialogResult.None);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions