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; }); }">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

task ReadContent(String^ filename) { anim->Start(); auto t = create_task(KnownFolders::DocumentsLibrary-> GetFileAsync(filename)).then( [](StorageFile^

Similar presentations


Presentation on theme: "task ReadContent(String^ filename) { anim->Start(); auto t = create_task(KnownFolders::DocumentsLibrary-> GetFileAsync(filename)).then( [](StorageFile^"— Presentation transcript:

1

2

3

4

5

6

7

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; } });

10

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());

15

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

17

18

19

20 ArrayReference buffer(bytes, count);

21 Buffers (demo)

22

23 Influence future design decisions SIGN UP @ http://bit.ly/x6dtHt

24

25

26 Not a problem in practice

27

28 Platform-specific (C++/CX)Standard C++


Download ppt "task ReadContent(String^ filename) { anim->Start(); auto t = create_task(KnownFolders::DocumentsLibrary-> GetFileAsync(filename)).then( [](StorageFile^"

Similar presentations


Ads by Google