I am creating an application and in that it need to send argument to the other page and send argument using the Messagingcenter when I send using MessagingCenter it call more than one time.
If I am using unscribe than in next time it is not receive next time.
MessagingCenter.Send(this, "Invoke", "Invokedtrue");
MessagingCenter.Subscribe<MyPage, string>(this, "Invoke", async (sender, arg) =>
{
await Process(arg);
});
MessagingCenter.Unsubscribe<MyPage>(this,"Invoke");
**ListPage**
private void ViewCell_Tapped(object sender, EventArgs e)
{
try
{
MessagingCenter.Send(this, "Invoke", "Invokedtrue");
}
catch (Exception ex)
{
Debug.Write(ex);
}
}
**Detail Page**
MessagingCenter.Subscribe<ListPage, string>(this, "Invoke", async (sender, arg) =>
{
await Process(arg);
});
private async Task Process(string arg)
{
//Here is api call to view detail of particular record
//Here I unsubscribe the MessagingCenter.
MessagingCenter.Unsubscribe<ListPage>(this,"Invoke");
}
I want to send only one time using subscribe and send only one time.
Can anyone look into this and suggest me what should I have to do in that?