I have a background service that calls the SelectOption()
method below. This needs to display an ActionSheet with the pre populated options, naturally this needs to be done on the UI thread.
My problem is that for each subsequent calls to the SelectOption()
function, I that number of ActionSheets displayed (e.g. second call, I get 2. third call I get 3 action sheets, etc).
Clearly I’m doing something wrong (perhaps the async
on the action) but how else would I do this to await the ActionSheet on the MainThread?
private void SelectOption()
{
MainThread.BeginInvokeOnMainThread(async () =>
{
var opt = await contentPage.DisplayActionSheet("Select From List", "cancel", null, options);
OptionSelected(opt);
});
}
I’ve tried a number of things including if action sheet displaying, don’t display again, but I’m sure this is going to cause a leak.