• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
As novidades do C# 5.0
 

As novidades do C# 5.0

on

  • 788 views

Por Paulo Morgado ...

Por Paulo Morgado

O novo paradigma de aplicações com ligação à nuvem leva a que a latência das comunicações seja maior do que aplicações totalmente locais. Para auxiliar o desenvolvimento deste novo paradigma, a última versão do C# 5.0 faz com que programação assíncrona pareça tão fácil como a programação síncrona

Statistics

Views

Total Views
788
Views on SlideShare
761
Embed Views
27

Actions

Likes
1
Downloads
0
Comments
0

1 Embed 27

http://evento.portugal-a-programar.pt 27

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    As novidades do C# 5.0 As novidades do C# 5.0 Presentation Transcript

    • NOME DA APRESENTAÇÃONome (Nick no Fórum)25 DE MAIO @MICROSOFTWhat’s New In C# 5.0Paulo Morgado (paulo.morgado)
    • Paulo MorgadoCodePlexRevistaPROGRAMAR
    • A Language For Each Generation# 3
    • The Evolution Of C## 4C# 1.0 C# 2.0 C# 3.0 C# 4.0 C# 5.0Managed Generics LINQ Dynamic Async
    • The Evolution Of C## 5C# 1.0 C# 2.0 C# 3.0 C# 4.0 C# 5.0Managed Generics LINQ Dynamic Asyncplease wait for the next slideclicking won’t make it come any faster
    • DEMOSynchronous UI Application
    • Introducing Async
    • Introducing Async - Yesterday# 8Clickvoid LoadImage(){// ...LoadLocalData(...);// ...}void Button_Click(...){LoadImage();UpdateView();}ClickMessagepump
    • Introducing Async - Today# 9Clickvoid LoadImage(){// ...DownloadRemoteData(...);// ...}void Button_Click(...){LoadImage();UpdateView();}ClickMessagepump
    • DEMOAdd the async & await keywords
    • Introducing Asyncasync void Button_Click(...){await LoadImageAsync();UpdateView();}async Task LoadImageAsync(){// ...await DownloadRemoteDataAsync(...);// ...}Messagepumpvoid LoadImage(){// ...DownloadRemoteData(...);// ...}void Button_Click(...){LoadImage();UpdateView();}Click
    • Introducing Async# 12Clickasync Task LoadImageAsync(){// ...await DownloadRemoteDataAsync(...);// ...}async void Button_Click(...){await LoadImageAsync();UpdateView();}ClickMessagepumpTask ...DownloadRemoteDataAsyncTask ...LoadImageAsyncDownloadLoadImage
    • DEMOAsync UI app: re-entrancy and deadlock
    • DEMOAsync with cancelation
    • DEMOAsync console app
    • DEMOAsync unit tests
    • Source Code Caller ID
    • Source Code Caller ID• CallerFilePathAttribute• Allows you to obtain the full path of the source file thatcontains the caller. This is the file path at the time ofcompile.• http://msdn.microsoft.com/library/system.runtime.compilerservices.callerfilepathattribute.aspx• CallerLineNumberAttribute• Allows you to obtain the line number in the source file atwhich the method is called.• http://msdn.microsoft.com/library/system.runtime.compilerservices.callerlinenumberattribute.aspx• CallerMemberNameAttribute• Allows you to obtain the method or property name of thecaller to the method.• http://msdn.microsoft.com/library/system.runtime.compilerservices.callermembernameattribute.aspx# 18
    • Source Code Caller ID - Examples# 19static void TraceMessage(string message,[CallerMemberName] string memberName = "",[CallerFilePath] string sourceFilePath = "",[CallerLineNumber] int sourceLineNumber = 0){Trace.WriteLine(string.Format("{0} at {1} in {2}:line {3}",message,memberName,sourceFilePath,sourceLineNumber));}
    • Source Code Caller ID - Examples# 20private string field;public string Property{get { return this.field; }set{if (this.field != value){this.field = value;this.NotifyPropertyChanged();}}}protected void NotifyPropertyChanged([CallerMemberName] string propertyName =""){// …}
    • Breaking Changes
    • Breaking Changes• You can use the iteration variable of a foreach statement in a lambdaexpression that’s contained in the body of the loop.• You can use the iteration variable of a foreach statement in a LINQexpression that’s contained in the body of the loop.• Overload resolution has been improved for calls that use named argumentsto access methods that contain params parameters.• Overload resolution is improved for calls where the algorithm must choosebetween a Func<object> parameter and a Func parameter that has adifferent type parameter (e.g., string or int?) for a Func<dynamic>argument.• Side effects from named and positional arguments in a method call nowoccur from left to right in the argument list.http://msdn.microsoft.com/library/hh678682(v=vs.110).aspx# 22
    • Resources
    • Resources• C# Reference• http://msdn.microsoft.com/library/618ayhy6.aspx• Breaking Changes in C# 5.0• http://msdn.microsoft.com/library/hh678682(v=vs.110).aspx• .NET Framework 4.5• http://msdn.microsoft.com/library/vstudio/w0x726c2(v=vs.110).aspx• Task Parallel Library (TPL)• http://msdn.microsoft.com/library/vstudio/dd460717.aspx• Asynchronous Programming with Async and Await (C#and Visual Basic)• http://msdn.microsoft.com/library/hh191443.aspx# 24
    • Resources• Task-based Asynchronous Pattern• http://msdn.microsoft.com/library/hh191443.aspx• Task.Run vs Task.Factory.StartNew• http://blogs.msdn.com/b/pfxteam/archive/2011/10/24/10229468.aspx• An Async Premier• http://msdn.microsoft.com/vstudio/jj573641.aspx• Eduasync by Jon Skeet• http://msmvps.com/blogs/jon_skeet/archive/tags/Eduasync/default.aspx• Eric Lipperts Blog• http://ericlippert.com/• http://blogs.msdn.com/b/ericlippert/archive/tags/c_2300_+5-0/async/# 25
    • Resources• Lucian Wischiks Blog• http://blogs.msdn.com/b/lucian/archive/tags/async/• Parallel Programming Team Blog• http://blogs.msdn.com/b/pfxteam/archive/tags/async/• What’s new in C#5? – Red Gate• http://www.youtube.com/watch?v=z7nry67oeKc• Novidades Do C# 5.0 – Comunidade NetPonto• http://www.youtube.com/watch?v=7Tl6CHf86z4• Sample Code• http://code.msdn.microsoft.com/C-50-AsyncAwait-Demo-Code-334679a5# 26
    • Resources• Paulo Morgado• @PauloMorgado• http://PauloMorgado.NET/• http://mvp.support.microsoft.com/profile/Paulo.Morgado• http://msmvps.com/blogs/paulomorgado/• http://weblogs.asp.net/paulomorgado/• http://pontonetpt.org/blogs/paulomorgado/• http://www.codeproject.com/Members/PauloMorgado• http://code.msdn.microsoft.com/site/search?f%5B0%5D.Type=User&f%5B0%5D.Value=Paulo%20Morgado• http://www.codeplex.com/UserAccount/UserProfile.aspx?UserName=PauloMorgado• http://www.slideshare.net/PauloJorgeMorgado# 27
    • Q&A
    • Patrocinador GoldPatrocinadores Silver
    • Media Partners
    • NOME DA APRESENTAÇÃONome (Nick no Fórum)25 DE MAIO @MICROSOFTThank You!Paulo Morgado (paulo.morgado)