We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to wait asynchronously until the popup closes(accept/decline button was hit)

Hello.We changed our popups in up with syncfusion popups but in some places we need the popups to be asynchronous/The show popup method to be awaitable.Is there any way to achieve this? Thanks,Regards

3 Replies

Subburaj Pandian Veluchamy January 11, 2019 10:47 AM UTC

Hi Tamas, 
 
Thank you for contacting Syncfusion support. 
 
Based on the provided information, we have checked your requirement of waiting asynchronously when closing the Popup layout by clicking accept / close option in Xamarin.Forms can be achievable by setting delay in the Closing event of PopupLayout. This event will while closing the Popup layout, using Cancel argument you can handle whether to close Popup or not. Please refer the following code example for the same, 
 
[c#] 
popupLayout.Closing += PopupLayout_Closing; 
 
        private void PopupLayout_Closing(object sender, System.ComponentModel.CancelEventArgs e) 
        { 
            var delay = System.DateTime.Now.AddMilliseconds(2000); 
            while (true) 
            { 
                if (System.DateTime.Now >= delay) 
                { 
                    e.Cancel = false; 
                    break; 
                } 
            } 
        } 
 
 
We have prepared sample based on your requirement by setting delay while opening and closing the Popup, please find the sample by the following link. 
 
 
 
Please let us know, if this helpful. 
 
Regards,
Subburaj Pandian V 


TC Tamas Cons replied to Subburaj Pandian Veluchamy January 14, 2019 08:42 AM UTC

Hi Tamas, 
 
Thank you for contacting Syncfusion support. 
 
Based on the provided information, we have checked your requirement of waiting asynchronously when closing the Popup layout by clicking accept / close option in Xamarin.Forms can be achievable by setting delay in the Closing event of PopupLayout. This event will while closing the Popup layout, using Cancel argument you can handle whether to close Popup or not. Please refer the following code example for the same, 
 
[c#] 
popupLayout.Closing += PopupLayout_Closing; 
 
        private void PopupLayout_Closing(object sender, System.ComponentModel.CancelEventArgs e) 
        { 
            var delay = System.DateTime.Now.AddMilliseconds(2000); 
            while (true) 
            { 
                if (System.DateTime.Now >= delay) 
                { 
                    e.Cancel = false; 
                    break; 
                } 
            } 
        } 
 
 
We have prepared sample based on your requirement by setting delay while opening and closing the Popup, please find the sample by the following link. 
 
 
 
Please let us know, if this helpful. 
 
Regards,
Subburaj Pandian V 


hello.thanks for the reply.No that is not the case I was looking for. 
The question is whether we can show the popup asynchronously or not.

Please find the following case:

if (!isValidPwd)
{
StopSpinningOperation();
var syncFusionConfirm = new SyncFusionAlert(string.Empty,
string.Format(AppResources.CHECK_NETWORK_KO, lcWiFiData.SSID),
xx.Localization.AppResources.CONTINUE,
xx.Localization.AppResources.CANCEL);
syncFusionConfirm.PopupView.DeclineCommand = new Command(() => { return; });
syncFusionConfirm.Show();
//DoStuff
}

I only want to execute the //DoStuff part when the user has hit accept(because as you can see on decline we want to exit the method syncFusionConfirm.PopupView.DeclineCommand = new Command(() => { return; }); ).
But in order to be able to achieve this,we need to wait until the user has hit accept or decline and not to continue with the flow until then.

How can we achieve this?
Thanks,Norbert

Note: //DoStuff is a complicated part ,and it does not work to put it in the AcceptCommand, we need to execute that after the popup has been "resolved"/closed.

Jagadeesan Pichaimuthu January 16, 2019 12:58 PM UTC

Hi Tamas, 

Thanks for the update. 

We have analyzed the reported query and you can perform your additional operation when popupview is open by using the Opened event in Xamarin.Forms. 

[C#] 
popupLayout.Opened += PopupLayout_Opened; 
 
private async void PopupLayout_Opened(object sender, EventArgs e) 
{ 
// Codes that needs to be executed once popup is visible in the screen. 
} 
 
We have prepared sample for your requirement please follow the below link. 
 
 
Please let us know, if this is helpful. 

Regards, 
Jagadeesan 

Loader.
Live Chat Icon For mobile
Up arrow icon