Created
October 6, 2012 22:03
-
-
Save chribben/3846317 to your computer and use it in GitHub Desktop.
Async gotcha in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async void AcquireFromCamera(object sender, RoutedEventArgs e) | |
{ | |
try | |
{ | |
var imageStream = await _cameraCapture.Shoot(); | |
var dto = new Dto(){ImageStream = imageStream}; | |
dto.Id = Guid.NewGuid().ToString(); | |
var file = await _fileHndlr.CreateFileAsync(dto.Id); | |
dto.ImageFilePath = file.Path; | |
_fileOperator.StoreStream(dto.ImageStream, file); | |
SaveNewDataItem(dto); | |
var dataItem = dataSource.GetItem(dto.Id); | |
StoreData(dataItem); | |
Frame.Navigate(typeof(EditDataPage), dto.Id); | |
} | |
catch (Exception ex) | |
{ | |
new MessageDialog(ex.Message).ShowAsync(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment