UserPopup does not close on first call Close

0
0

Hi,

I have a UserPopup with 2 buttons and one of them has async /await click event. I have to click twice to make it close:

private void btnClose_Click(object sender, EventArgs e)
{
//This closes on first click
this.Close();
}

private async void btnOK_Click(object sender, EventArgs e)
{
await Task.Delay(1000);
//This does not close on first click
this.Close();
}

Please take a look at it.

Thank you for your help,

Page,

  • You must to post comments
0
0

That’s because await exits the method so the response is terminated and Task.Delay() spawns another thread.

Add Application.Update(this); to push the update back to the client.

When you see it working on the second click is just because it’s also sending back the pending changes as soon as there is another request. The same would happen if you click anywhere else. Wisej makes it looks like a desktop app but on the web  you still have the request/response cycle.

 

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.