CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.

Home Page:https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No response was received for the given async request message

CodingOctocat opened this issue · comments

Describe the bug

I am using AsyncRequestMessage in MAUI, I have added a button in the group header of the CollectionView, clicking on the button sends an AsyncRequestMessage but sometimes it raises an exception System.InvalidOperationException: 'No response was received for the given request message.' What I mean is that I may click on the button 1, 2, 5 ... times and it will be fine, but maybe it will raise this exception.

Regression

No response

Steps to reproduce

AsyncRequestMessage

public class DisplayActionSheetAsyncRequestMessage : AsyncRequestMessage<string>
{
    public string[] Buttons { get; }

    public string? Cancel { get; }

    public string? Destruction { get; }

    public string? Title { get; }

    public DisplayActionSheetAsyncRequestMessage(string? title, string? cancel, string? destruction, params string[] buttons)
    {
        Title = title;
        Cancel = cancel;
        Destruction = destruction;
        Buttons = buttons;
    }
}

Sender

string action = await Messenger.Send(new DisplayActionSheetAsyncRequestMessage(
    "Test Title",
    "Cancel",
    null,
    "action1", "action2"));

Receiver

// at ContentPage ctor:
WeakReferenceMessenger.Default.Register<MyContentPage, DisplayActionSheetAsyncRequestMessage>(this,
     (r, m)
         => m.Reply(r.DisplayActionSheet(m.Title, m.Cancel, m.Destruction, m.Buttons))
 );

Expected behavior

It's always normal. It's not raise System.InvalidOperationException: No response was received for the given async request message

Screenshots

No response

IDE and version

VS 2022

IDE version

17.10.3

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

8.2.2

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item