Asynchronous programming Using Task, async and await Asynchronous programming1.

Slides:



Advertisements
Similar presentations
Software development. Chapter 8 – Advanced Topics.
Advertisements

Developing for Windows 8/WinRT Session 4 Fundamentals Kevin Stumpf.
Async Programming WITH ASYNC TASK
 2005 Pearson Education, Inc. All rights reserved Introduction.
Threads in C# Threads in C#.
Essential Introduction to Computers. What is a Computer? An electronic device, operating under the control of instructions stored in its own memory, that.
INTERNET DATABASE Chapter 9. u Basics of Internet, Web, HTTP, HTML, URLs. u Advantages and disadvantages of Web as a database platform. u Approaches for.
Intro to Computers Test 1 – Chapters 1 & 2 and Windows Fall 2005.
Chapter 2: Input, Processing, and Output
Introduction to Active Server Pages
Course Map The Java Programming Language Basics Object-Oriented Programming Exception Handling Graphical User Interfaces and Applets Multithreading Communications.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 12-1 David M. Kroenke’s Chapter Twelve: ODBC Database Processing: Fundamentals,
Software development. Chapter 5 – Data management.
Linux Operations and Administration
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
TC2-Computer Literacy Mr. Sencer February 8, 2010.
INTRODUCTION TO WEB DATABASE PROGRAMMING
A First Program Using C#
Networking Nasrullah. Input stream Most clients will use input streams that read data from the file system (FileInputStream), the network (getInputStream()/getInputStream()),
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
ITIS 1210 Introduction to Web-Based Information Systems Chapter 24 How Websites Work with Databases How Websites Work with Databases.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Bookstore Web Application Introducing Visual Web Developer 2008 Express and the.
CS378 - Mobile Computing Web - WebView and Web Services.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
ASP.NET Programming with C# and SQL Server First Edition
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
Postacademic Interuniversity Course in Information Technology – Module C1p1 Contents Data Communications Applications –File & print serving –Mail –Domain.
Unit 1 – Web Concepts Instructor: Brent Presley. ASSIGNMENT Read Chapter 1 Complete lab 1 – Installing Portable Apps.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Microsoft Excel 2007 © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line.
Database-Driven Web Sites, Second Edition1 Chapter 5 WEB SERVERS.
Chapter 11 An Introduction to Visual Basic 2008 Why Windows and Why Visual Basic How You Develop a Visual Basic Application The Different Versions of Visual.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Hour 7 The Application Layer 1. What Is the Application Layer? The Application layer is the top layer in TCP/IP's protocol suite Some of the components.
Consuming REST Services from C# SoftUni Team Technical Trainers Software University
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Interfaces 1. Interfaces are (parts of) contracts Interfaces are contracts between implementers and consumers Consumers: Programmers using a class implementing.
Joe Hummel, PhD Microsoft MVP Visual C++ Technical Staff: Pluralsight, LLC Professor: U. of Illinois, Chicago stuff:
Module 10 Administering and Configuring SharePoint Search.
What’s new in Kentico CMS 5.0 Michal Neuwirth Product Manager Kentico Software.
Chapter 11 An Introduction to Visual Basic 2005 Why Windows and Why Visual Basic How You Develop a Visual Basic Application The Different Versions of Visual.
JavaScript Syntax, how to use it in a HTML document
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
1 Web Servers (Chapter 21 – Pages( ) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3 System Architecture.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 12-1 David M. Kroenke’s Chapter Twelve: ODBC, OLE DB, ADO, and ASP Part.
1 Title: Introduction to Computer Instructor: I LTAF M EHDI.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
PROGRAMMING IN VISUAL BASIC.NET CREATING YOUR FIRST WEB APPLICATION Bilal Munir Mughal 1 Chapter-3.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
LINQ Language Integrated Query LINQ1. LINQ: Why and what? Problem Many data sources: Relational databases, XML, in-memory data structures, objects, etc.
ASP Syntax Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Presented By:. What is JavaHelp: Most software developers do not look forward to spending time documenting and explaining their product. JavaSoft has.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
Internet Searching the World Wide Web. The Internet and the World Wide Web The Internet is a worldwide collection of networks that allows people to communicate.
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
Introduction to Enterprise Search Corey Roth Blog: Twitter: twitter.com/coreyrothtwitter.com/coreyroth.
Introduction to Visual Basic 2008 Programming
12 Asynchronous Programming
Creating Windows Store Apps Using Visual Basic
Internet Technologies I - Lect.01 - Waleed Ibrahim Osman
Database Processing: David M. Kroenke’s Chapter Twelve: Part One
Presentation transcript:

Asynchronous programming Using Task, async and await Asynchronous programming1

Responsive user interfaces Users expect modern user interfaces to be responsive If the user interface must not “freeze” if the user starts a long-running task. Example long-running tasks Sending or receiving data on a network Communication with a potentially slow server Including database servers, web servers, etc. Performing time consuming calculations Reading or writing files on the local hard disk When the user initiates a task that is assumed to be long-running we must execute the task in a separate thread “Separate” means not in the GUI thread Asynchronous programming2

Keywords: await and async Two C# keywords: await + async Syntax: await expression Example: Await Task.whenAll(task1, task2, …., taskN) Awaits termination of all task listed await is used to await(!) the termination of a task Normally waiting for the result of the task. In the meantime the method that called the method containing the await will execute When the awaited expression has terminated, control comes back to the method … Which can then use the result to display, etc. A method is declared async if there is an await statement inside the method Example: GuiExampleAsyncWait Asynchronous programming3

API async methods Some classes has support for async programming Example: HttpClient With HttpClient you can download the contents of a document specifying the documents URL Task getStringTask = httpClient.getStringAsync(“ String urlContents = await getStringTask; Example: SimpleBrowserAsync System.IO.Stream has some async methods Asynchronous programming4

References and further readings MSDN Asynchronous Programming with Async and Await John Sharp: Microsoft Visual C# 2012 Step by Step, Chapter 24 Improving Response Time by Performing Asynchronous Operations, page Deitel & Deitel: Visual C# 2013, How To Programing, 5 th edition, Pearson 2014 Chapter 28 Asynchronous Programming with async and await, 26 pages Available as a web-only chapter from Companion Web site l l Asynchronous programming5