Esempio n. 1
0
 public BadMainViewModelA()
 {
     // BAD CODE!!!
     UrlByteCount =
         MyStaticService.CountBytesInUrlAsync("http://www.example.com").Result;
     // APP wont show up until this code finishes.
     // Possibility of deadlock.
 }
Esempio n. 2
0
 public MainViewModel()
 {
     UrlByteCount = new NotifyTaskCompletion <int>(
         MyStaticService.CountBytesInUrlAsync("http://www.example.com"));
 }
Esempio n. 3
0
 // BAD CODE!!!
 // any errors raised by the asynchronous operation will crash the application by default
 private async void Initialize()
 {
     UrlByteCount = await MyStaticService.CountBytesInUrlAsync(
         "http://www.example.com");
 }