C# 5.0 Alex Davies 22 nd December 2011. What we will cover C# 5.0,.NET 4.5, Visual Studio 11 Caller Info Attributes Upgrade from synchronous to asynchronous.

Slides:



Advertisements
Similar presentations
Error-handling using exceptions
Advertisements

Exceptions Chapter Throwing and Catching Exceptions When a program runs into a problem that it cannot handle, it throws an exception. Exceptions.
Exception Handling The purpose of exception handling is to permit the program to catch and handle errors rather than letting the error occur and suffer.
Exceptions Don’t Frustrate Your User – Handle Errors KR – CS 1401 Spring 2005 Picture – sysprog.net.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
C++ Exception Handling
The Web Warrior Guide to Web Design Technologies
Async Programming WITH ASYNC TASK
Lecture 28 More on Exceptions COMP1681 / SE15 Introduction to Programming.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
Lecture 27 Exam outline Boxing of primitive types in Java 1.5 Generic types in Java 1.5.
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.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Exception Handling An Exception is an indication of a problem that occurs during a program’s execution. Exception handling enables the programmer to create.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 7 Improving the User Interface
Managed Code Generics Language Integrated Query Dynamic + Language Parity C# VB 11.0 Windows Runtime + Asynchrony C# VB 7.0 C# VB.
Interesting facts about node.js.  Asynchronous I/O  How do they do that?..threads (usually) What do Web Servers do?
Introduction to Computer Programming Error Handling.
Parallel Programming in Java with Shared Memory Directives.
What is an exception? An exception is: – an event that interrupts the normal processing of the program. –an error condition that violates the semantic.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
06 Exception Handling. 2 Contents What is an Exception? Exception-handling in Java Types of Exceptions Exception Hierarchy try-catch()-finally Statement.
1 CSC241: Object Oriented Programming Lecture No 27.
COMPUTER PROGRAMMING 2 Exceptions. What are Exceptions? Unexpected events that happen when the code is executing (during runtime). Exceptions are types.
Joe Hummel, PhD Technical Staff: Pluralsight Adjunct Professor: UIC, LUC
Exceptions 1. Your computer takes exception Exceptions are errors in the logic of a program (run-time errors). Examples: Exception in thread “main” java.io.FileNotFoundException:
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
Program documentation Using the Doxygen tool Program documentation1.
Consuming REST Services from C# SoftUni Team Technical Trainers Software University
Module 3: Working with Components. Overview An Introduction to Key.NET Framework Development Technologies Creating a Simple.NET Framework Component Creating.
Joe Hummel, PhD Microsoft MVP Visual C++ Technical Staff: Pluralsight, LLC Professor: U. of Illinois, Chicago stuff:
Introduction to Exception Handling and Defensive Programming.
Joe Hummel, the compiler is at your service Chicago Code Camp 2014.
Future of VB and C# Lucian Wischik VB Language PM Microsoft.
WHO WILL BENEFIT FROM THIS TALK TOPICS WHAT YOU’LL LEAVE WITH ASP.NET developers, including Web Forms & MVC History of async programming in.NET How async.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
Joe Hummel, the compiler is at your service SDC Meetup, Sept 2014.
Exception Handling in C++. Outline What exceptions are and when to use them Using try, catch and throw to detect, handle and indicate exceptions, respectively.
Other news? async and await Anonymous types (var, dynamic) Tuples Object instantiation Extension methods UCN Teknologi/act2learn1FEN 2014.
Exceptions Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Exception Handling How to handle the runtime errors.
CSC241 Object-Oriented Programming (OOP) Lecture No. 22.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
C# Present and Future Marita Paletsou Software Engineer.
ECE122 L23: Exceptions December 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 24 Exceptions.
Introduction to Exceptions in Java CS201, SW Development Methods.
1 Handling Errors and Exceptions Chapter 6. 2 Objectives You will be able to: 1. Use the try, catch, and finally statements to handle exceptions. 2. Raise.
Winter 2006CISC121 - Prof. McLeod1 Last Time Reviewed class structure: –attributes –methods –(inner classes) Looked at the effects of the modifiers: –public.
Garbage Collection It Is A Way To Destroy The Unused Objects. To do so, we were using free() function in C language and delete() in C++. But, in java it.
Joe Hummel, the compiler is at your service Chicago Coder Conference, June 2016.
Async Made Simple in Windows 8, with C# and Visual Basic Alex Turner Program Manager VB/C# Compilers Microsoft Corporation DEV332.
Asynchronous Programming Writing Concurrent Code in C# SoftUni Team Technical Trainers Software University
Exception Handling in C++
16 Exception Handling.
Coding Defensively Coding Defensively
New Features of C# Kuppurasu Nagaraj Microsoft Connect 2016
Indexer AKEEL AHMED.
12 Asynchronous Programming
Creating Windows Store Apps Using Visual Basic
ATS Application Programming: Java Programming
Conditional Statements
Exception Handling CSCI293 - C# October 3, 2005.
Part B – Structured Exception Handling
Programming in C# Lesson 5. Exceptions..
Debugging and Handling Exceptions
Java Basics Exception Handling.
Chapter 11: Exception Handling
CMSC 202 Exceptions.
Presentation transcript:

C# 5.0 Alex Davies 22 nd December 2011

What we will cover C# 5.0,.NET 4.5, Visual Studio 11 Caller Info Attributes Upgrade from synchronous to asynchronous Catching the asynchronous error Performance tuning Roslyn Pizza

A Note on Versions C# Version.NET VersionDevelopment Environment 1.0 Visual Studio.NET Visual Studio.NET Visual Studio , 3.0, 3.5Visual Studio Visual Studio Visual Studio 11 Developer preview

What’s in C# 5.0 Caller Info Attributes Asynchronous Programming Model Roslyn - Compiler as a Service (sort of)

Caller Info Attributes Injects information about the methods caller into parameters Not in developer preview public static void Log(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0, [CallerMemberName] string member = "") { Console.WriteLine("{0}:{1} – {2}: {3}", file, line, member, message); }

Asynchronous Programming Traditionally applications would stall on blocking IO async / await prevents blocking First part of the method runs synchronously await saves state returns the current method. When awaited task finishes the rest of the method is scheduled to run await must be within an async method

Error Handling Exceptions are thrown on await (even if thrown in the synchronous part of the code) If it is an async void method, unhandled exception is thrown If you never await a task two options –Hide the error (this is default) –Throw an unhandled exception next time GC runs Can listen and handle exceptions on the TaskSchedular.UnobservedTaskExceptions event

Squeezing out the performance Async methods are not normal methods Task.ConfigureAwait(continueOnCaptured Context:true); does not bother about continuing on same thread Compiler optimizes for complete tasks Cache completed tasks rather than caching data

Roslyn – Compiler as a Service Not really part of C# 5.0, but closely related Currently in CTP Offers better interaction with the compiler, allowing access to syntax trees, symbol tables and all other compiler internals Allows for easy to use scripting var engine = new ScriptEngine(); Roslyn"");"); var engine = new ScriptEngine(); Code is Great"");“ );

Summary Slide Caller Info Attributes to get meta information C# 5.0 is really all about async Two new keywords allow writing asynchronous code in a synchronous style Take care of errors, need to know what can and can’t be caught Roslyn for dynamic code generation