Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No response was received for the given async request message #898

Open
1 of 4 tasks
CodingOctocat opened this issue Jul 5, 2024 · 1 comment
Open
1 of 4 tasks
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior

Comments

@CodingOctocat
Copy link

CodingOctocat commented Jul 5, 2024

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

@CodingOctocat CodingOctocat added the bug 🐛 An unexpected issue that highlights incorrect behavior label Jul 5, 2024
@bukowa
Copy link

bukowa commented Oct 16, 2024

Can you try changing this to WeakReferenceMessenger.Default here ?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior
Projects
None yet
Development

No branches or pull requests

2 participants