Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to remove async error while running window application in visual studio c#?

user-image
Question ajoutée par kamal rajak , Software engineer , Newgen software ltd
Date de publication: 2016/03/02
shoheb mohammed abdul
par shoheb mohammed abdul , Associate Software Developer , Bizmatic Solutions Private Limited

s correct if your asynchronous work (Task.Delay) is meaningless. The difference is that a synchronous handler is completed immediately (synchronously), so the form cannot possibly close before textBox is updated.

Renu Jacob
par Renu Jacob , IT Engineer , Al Ajjaj Ltd

There are various methods to remove async error

 

The complicated one is to

Run Multiple Operations and Queue the Output

The app starts another asynchronous operation each time that the user chooses the Event and all the operations run to completion. All the requested operations list asynchronously, but the output from the operations is presented sequentially. The list of results for each group is presented separately.

 

The operations share a global Task, pendingWork, which serves as a gatekeeper for the display process.

 

private async void StartButton_Click(object sender, RoutedEventArgs e) { // ***Verify that each group's results are displayed together, and that // the groups display in order, by marking each group with a letter. group = (char)(group +1); ResultsTextBox.Text += string.Format("\\r\\n\\r\\n#Starting group {0}.", group); try { // *** Pass the group value to AccessTheWebAsync. char finishedGroup = await AccessTheWebAsync(group); // The following line verifies a successful return from the download and // display procedures. ResultsTextBox.Text += string.Format("\\r\\n\\r\\n#Group {0} is complete.\\r\\n", finishedGroup); } catch (Exception) { ResultsTextBox.Text += "\\r\\nDownloads failed."; } }

More Questions Like This