Guest User

Untitled

a guest
Nov 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. // meanwhile: show the user that you are busy:
  2. this.ShowBusy(true); // show picture box?
  3.  
  4. // if needed do other things you can do before the data is fetched
  5. this.ClearTable();
  6.  
  7. // once you have nothing meaningful to do, await for your data
  8. MyData fetchedData = await fetchDataTask;
  9. this.ProcessData(fetchedData);
  10.  
  11. // finished:
  12. this.ShowBusy(false); // remove picture box
  13.  
  14. // continue while opening:
  15. using (var sqlCommand = new SqlCommand(...))
  16. {
  17. cmd.Parameters.AddWithValue(...);
  18.  
  19. // before executing the query: wait until OpenAsync finished:
  20. await taskOpen;
  21.  
  22. // read the data. If nothing to do: await, otherwise use Task similar to Open
  23. SqlDataReader dataReader = await cmd.ExecuteReaderAsync();
  24. foreach (var row in dataReader)
  25. {
  26. ... (some Await with GetFieldValueAsync
  27. }
  28. }
  29. }
Add Comment
Please, Sign In to add comment