[BUG] WeakReferenceMessenger breaking change: stopped working
softlion opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
weakmessenger messages are not received anymore
Expected Behavior
The message should be received
Steps To Reproduce
public static async Task NavigateToSomething()
{
var tcs = new TaskCompletionSource<MyResult>();
WeakReferenceMessenger.Default.Register<MyResult>(tcs, async (_,result) =>
{
//Message never received
WeakReferenceMessenger.Default.Unregister<MyResult>(tcs);
tcs.TrySetResult(result);
});
await Navigation.PushModalAsync(new MyPage());
var result = await tcs.Task;
...
}
Link to public reproduction project repository
none
Environment
- .NET MAUI CommunityToolkit: 9.0.2
- OS: Android and iOS
- .NET MAUI: 8.0.70
Anything else?
I was able to repro that issue on an android simulator, and on an iOS device.
The exact same code was working as expected in previous versions of Community toolkit.
The only workaround is to replace the WeakReferenceMessenger by the StrongReferenceMessenger.
WeakReferenceMessanger
is not in the .NET MAUI Community Toolkit.
Please open this issue in https://github.com/communitytoolkit/dotnet