OpenAsync(FileAccessMode::Read); }).then( [](IRandomAccessStream^ stream) { auto inputStream = stream->GetInputStreamAt(0); auto dr = ref new DataReader(inputStream); return dr->LoadAsync(stream->Size); }).then( [](unsigned int count) { // read content txtContent->Text = content; }); }"> OpenAsync(FileAccessMode::Read); }).then( [](IRandomAccessStream^ stream) { auto inputStream = stream->GetInputStreamAt(0); auto dr = ref new DataReader(inputStream); return dr->LoadAsync(stream->Size); }).then( [](unsigned int count) { // read content txtContent->Text = content; }); }">
Download presentation
Presentation is loading. Please wait.
Published byGabriel Johnston Modified over 9 years ago
8
task ReadContent(String^ filename) { anim->Start(); auto t = create_task(KnownFolders::DocumentsLibrary-> GetFileAsync(filename)).then( [](StorageFile^ file) { return file->OpenAsync(FileAccessMode::Read); }).then( [](IRandomAccessStream^ stream) { auto inputStream = stream->GetInputStreamAt(0); auto dr = ref new DataReader(inputStream); return dr->LoadAsync(stream->Size); }).then( [anim](unsigned int count) { anim->End(); // read content return content; }); return t; } Async & Exceptions
9
anim->Start(); auto t = create_task(KnownFolders::DocumentsLibrary-> GetFileAsync("Log.txt")).then( [](StorageFile^ file) { return file->OpenAsync(FileAccessMode::Read); }).then( [](IRandomAccessStream^ stream) { auto inputStream = stream->GetInputStreamAt(0); auto dr = ref new DataReader(inputStream); return dr->LoadAsync(stream->Size); }).then( [anim](unsigned int count) { anim->End(); // read content }); return t; [anim](unsigned int count) { anim->End(); // read content }); Async & Exceptions [anim](task lt) { anim->End(); // read content }); [anim](task lt) { anim->End(); try { unsigned int count = lt.get(); // read content } catch(AccessDeniedException^ ex) { throw; } });
11
void MainPage::OnNavigatedTo(NavigationEventArgs^ e) { create_task(KnownFolders::DocumentsLibrary-> GetFileAsync(“Surface.ini")).then( [](StorageFile^ file) { return file->OpenAsync(FileAccessMode::Read); }).then( [](IRandomAccessStream^ stream) { auto inputStream = stream->GetInputStreamAt(0); auto dr = ref new DataReader(inputStream); return dr->LoadAsync(stream->Size); }).then( [](unsigned int count) { // read content txtContent->Text = content; }); }
12
void MainPage::OnNavigatedTo(NavigationEventArgs^ e) { create_task(KnownFolders::DocumentsLibrary-> GetFileAsync(“Surface.ini")).then( [](StorageFile^ file) { return file->OpenAsync(FileAccessMode::Read); }).then( [](IRandomAccessStream^ stream) { auto inputStream = stream->GetInputStreamAt(0); auto dr = ref new DataReader(inputStream); return dr->LoadAsync(stream->Size); }).then( [](unsigned int count) { // read content txtContent->Text = content; }); }
13
void MainPage::OnNavigatedTo(NavigationEventArgs^ e) { create_task(KnownFolders::DocumentsLibrary-> GetFileAsync(“Surface.ini")).then( [](StorageFile^ file) { return file->OpenAsync(FileAccessMode::Read); }).then( [](IRandomAccessStream^ stream) { auto inputStream = stream->GetInputStreamAt(0); auto dr = ref new DataReader(inputStream); return dr->LoadAsync(stream->Size); }).then( [](unsigned int count) { // read content txtContent->Text = content; }); } void MainPage::OnNavigatedTo(NavigationEventArgs^ e) { create_task(KnownFolders::DocumentsLibrary-> GetFileAsync(“Surface.ini")).then( [](StorageFile^ file) { return file->OpenAsync(FileAccessMode::Read); }, task_continuation_context::use_arbitrary()).then( [](IRandomAccessStream^ stream) { auto inputStream = stream->GetInputStreamAt(0); auto dr = ref new DataReader(inputStream); return dr->LoadAsync(stream->Size); }, task_continuation_context::use_arbitrary()).then( [](unsigned int count) { // read content txtContent->Text = content; }, task_continuation_context::use_current()); }
14
//....then([content](unsigned int count) { // read content }, task_continuation_context::use_arbitrary()).then([content]() { txtContent->Text = *content; }, task_continuation_context::use_current());
16
Performance Portability Coding style “It would be a mistake, and we are absolutely not telling you, to go rush out and say, 'every class I ever wrote should now be a ref class or a value class and I shouldn't use those old standard things any more” Herb Sutter //BUILD/ 2011
20
ArrayReference buffer(bytes, count);
21
Buffers (demo)
23
Influence future design decisions SIGN UP @ http://bit.ly/x6dtHt
26
Not a problem in practice
28
Platform-specific (C++/CX)Standard C++
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.