question

Gavin-8888 avatar image
0 Votes"
Gavin-8888 asked ·

ContentDialog PrimaryButtonClick closes the dialog before the async operation completes.

Hi

I have a ContentDialog, when I click on the primary button the PrimaryButtonClick event is raised which then calls an async operation. But before the async operation completes the dialog is closed. Is there a way to prevent this?


 private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
      IsPrimaryButtonEnabled = IsSecondaryButtonEnabled = false;
    
      bool result = false;   
    
      try
      {
           result = await REST.SetOffersAsync();
           if (!result) {
                 args.Cancel = true;
                 IsSecondaryButtonEnabled = true;
           }
      }
      catch (Exception ex)
      {
           args.Cancel = true;
           IsSecondaryButtonEnabled = true;
             
      }                  
  }

Thanks

Gavin

windows-uwp
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Gavin-8888 avatar image
0 Votes"
Gavin-8888 answered ·

Okay, found the solution. I need to use args.GetDeferral();

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KevinAaron-7957 avatar image
0 Votes"
KevinAaron-7957 answered ·

smoething Please help the Asp.net Malware functon!

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.