ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل kamal rajak , Software engineer , Newgen software ltd
تاريخ النشر: 2016/03/02
shoheb mohammed abdul
من قبل 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
من قبل 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."; } }

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟