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

Slides:



Advertisements
Similar presentations
For(int i = 1; i
Advertisements

Jan Java I/O Yangjun Chen Dept. Business Computing University of Winnipeg.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
void count_down (int count) { for(i=count; i>1; i--) printf(" %d\t", count); } printf("A%d\n", count); if(count>1) count_down(count-1); printf("B%d\n",
Writing “Exception Safe” C++ Alan Griffiths –Work: Experian Limited Senior Systems Consultant Mentoring & development OOA/OOD/C++
Passing Streams to Functions. Passing Streams to Functions One Rule: always pass a stream as a reference.
Divisor máximo de dois inteiros. unsigned int gcd(unsigned int A, unsigned int B) { if (B > A) return gcd(B,A); else if (B==0) return A; else return gcd(B,A%B);}
C Intro.
C++ await Deon Brewis std::future additions:
Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University.
Copyright © 2012 Pearson Education, Inc. Chapter 8 Exception Handling.
C Programming - Lecture 5
Unit 201 FILE IO Types of files Opening a text file for reading Reading from a text file Opening a text file for writing/appending Writing/appending to.
Exceptions Used to signal errors or unexpected situations to calling code Should not be used for problems that can be dealt with reasonably within local.
CS 311 – Lecture 10 Outline Review open() and close() Difference between fopen() and open() File management system calls – read() – write() – lseek() –
James Tam Simple File Input And Output Types of Java Files Simple File Output in Java Simple File Input in Java.
7/2/2015CS2621 OO Design and Programming II I/O: Reading and Writing.
Using java’s Scanner class To read from input and from a file. (horstmann ch04 and ch 17)
Java Programming: I/O1 Java I/O Reference: java.sun.com/docs/books/tutorial/essential/io/
1 Operator Overloading in C++ Copyright Kip Irvine, All rights reserved. Only students enrolled in COP 4338 at Florida International University may.
CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail.
Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 9/19/2015 Review of 50% OF ENCM369 in 50 minutes1.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
Bags Chapter 1 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
CPSC 872 John D. McGregor Session 21 Architecture Design, cont’d.
Chapter 9 1 Chapter 9 – Part 1 l Overview of Streams and File I/O l Text File I/O l Binary File I/O l File Objects and File Names Streams and File I/O.
Given an integer value stored in a variable, develop an algorithm to print the value to the display device. Integer Output Note that the value could be.
SE-1021 Software Engineering II Week 8, Class 1 Return Exam Producing UML diagrams automatically in EA Poll Everywhere Files Tomorrow Week 6 HW due (if.
1 Week 12 l Overview of Streams and File I/O l Text File I/O Streams and File I/O.
C ++ Basics by Bindra Shrestha sce.uhcl.edu/shresthab CSCI 3333 Data Structures.
Async everywhere: creating responsive APIs & apps
Data Communications and Networking COMP 2330 Laboratory 6 Mr. Wilman ZOU Please sign your name with your attendance.
CSC 107 – Programming For Science. Today’s Goal  Discuss writing functions that return values  return statement’s meaning and how it works  When and.
A stream is a sequence of data. A stream is a flowing sequence of characters.
CS101 Lab “File input/Output”. File input, output File : binary file, text file READ/WRITE class of “text file” - File Reading class : FileReader, BufferedReader.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Loops and Input COMP 102 #
CSI 3125, Preliminaries, page 1 Java I/O. CSI 3125, Preliminaries, page 2 Java I/O Java I/O (Input and Output) is used to process the input and produce.
3. The Nuts and Bolts of C++ Computer Programming 3. The Nuts and Bolts of C++ 1 Learning the C++ language 3. The Nuts and Bolts of C++ 16 September 2008.
Async Made Simple with C++ PPL
GAME203 – C Files stdio.h C standard Input/Output “getchar()”
1 Lecture 9: Network programming. 2 Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
C++ Basics Programming. COMP104 Lecture 5 / Slide 2 Introduction to C++ l C is a programming language developed in the 1970s with the UNIX operating system.
Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 2/26/2016 Review of 50% OF ENCM369 in 50 minutes1.
Using MPI on Dept. Clusters Min LI Sep Outline Run MPI programs on single machine Run mpi programs on multiple machines Assignment 1.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 3/3/2016 Review of 50% OF ENCM369 in 50 minutes1.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
File Input & Output Sections Outcomes  Know the difference between files and streams  Use a Scanner to read from a file  add “throws” annotations.
C# 5.0 Alex Davies 22 nd December What we will cover C# 5.0,.NET 4.5, Visual Studio 11 Caller Info Attributes Upgrade from synchronous to asynchronous.
Exception Handling. VB.NET has an inbuilt class that deals with errors. The Class is called Exception. When an exception error is found, an Exception.
1 Text File Input and Output. Objectives You will be able to Write text files from your Java programs. Read text files in your Java programs. 2.
2.1 First C Program. First Program Open visual studio, click new file Save as “programName.c” – Program must start with letter and have no spaces – Must.
4 Starting Tips to Keep Your Car in Top Condition
OO Design and Programming II I/O: Reading and Writing
Program Input/Output (I/O)
SE-1021 Software Engineering II
Using the Windows Runtime from C# and Visual Basic
Learning Objectives What else in C++ Bitwise operator
URL in Java C343 Lab (Week 13).
Pointers & Functions.
Assembly Language Review
Sadalage & Fowler (Amazon)
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Pointers & Functions.
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Building Blocks of C Programming Language
Constructors and Deconstructor
The ‘asm’ construct An introduction to the GNU C/C++ compiler’s obscure syntax for doing inline assembly language.
Presentation transcript:

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

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

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

//....then([content](unsigned int count) { // read content }, task_continuation_context::use_arbitrary()).then([content]() { txtContent->Text = *content; }, task_continuation_context::use_current());

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

ArrayReference buffer(bytes, count);

Buffers (demo)

Influence future design decisions SIGN

Not a problem in practice

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