Your SlideShare is downloading. ×
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 slidec...
DEMOSynchronous UI Application
Introducing Async
Introducing Async - Yesterday# 8Clickvoid LoadImage(){// ...LoadLocalData(...);// ...}void Button_Click(...){LoadImage();U...
Introducing Async - Today# 9Clickvoid LoadImage(){// ...DownloadRemoteData(...);// ...}void Button_Click(...){LoadImage();...
DEMOAdd the async & await keywords
Introducing Asyncasync void Button_Click(...){await LoadImageAsync();UpdateView();}async Task LoadImageAsync(){// ...await...
Introducing Async# 12Clickasync Task LoadImageAsync(){// ...await DownloadRemoteDataAsync(...);// ...}async void Button_Cl...
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 cal...
Source Code Caller ID - Examples# 19static void TraceMessage(string message,[CallerMemberName] string memberName = "",[Cal...
Source Code Caller ID - Examples# 20private string field;public string Property{get { return this.field; }set{if (this.fie...
Breaking Changes
Breaking Changes• You can use the iteration variable of a foreach statement in a lambdaexpression that’s contained in the ...
Resources
Resources• C# Reference• http://msdn.microsoft.com/library/618ayhy6.aspx• Breaking Changes in C# 5.0• http://msdn.microsof...
Resources• Task-based Asynchronous Pattern• http://msdn.microsoft.com/library/hh191443.aspx• Task.Run vs Task.Factory.Star...
Resources• Lucian Wischiks Blog• http://blogs.msdn.com/b/lucian/archive/tags/async/• Parallel Programming Team Blog• http:...
Resources• Paulo Morgado• @PauloMorgado• http://PauloMorgado.NET/• http://mvp.support.microsoft.com/profile/Paulo.Morgado•...
Q&A
Patrocinador GoldPatrocinadores Silver
Media Partners
NOME DA APRESENTAÇÃONome (Nick no Fórum)25 DE MAIO @MICROSOFTThank You!Paulo Morgado (paulo.morgado)
Upcoming SlideShare
Loading in...5
×

As novidades do C# 5.0

585

Published on

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

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
585
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "As novidades do C# 5.0"

  1. 1. NOME DA APRESENTAÇÃONome (Nick no Fórum)25 DE MAIO @MICROSOFTWhat’s New In C# 5.0Paulo Morgado (paulo.morgado)
  2. 2. Paulo MorgadoCodePlexRevistaPROGRAMAR
  3. 3. A Language For Each Generation# 3
  4. 4. The Evolution Of C## 4C# 1.0 C# 2.0 C# 3.0 C# 4.0 C# 5.0Managed Generics LINQ Dynamic Async
  5. 5. 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
  6. 6. DEMOSynchronous UI Application
  7. 7. Introducing Async
  8. 8. Introducing Async - Yesterday# 8Clickvoid LoadImage(){// ...LoadLocalData(...);// ...}void Button_Click(...){LoadImage();UpdateView();}ClickMessagepump
  9. 9. Introducing Async - Today# 9Clickvoid LoadImage(){// ...DownloadRemoteData(...);// ...}void Button_Click(...){LoadImage();UpdateView();}ClickMessagepump
  10. 10. DEMOAdd the async & await keywords
  11. 11. Introducing Asyncasync void Button_Click(...){await LoadImageAsync();UpdateView();}async Task LoadImageAsync(){// ...await DownloadRemoteDataAsync(...);// ...}Messagepumpvoid LoadImage(){// ...DownloadRemoteData(...);// ...}void Button_Click(...){LoadImage();UpdateView();}Click
  12. 12. Introducing Async# 12Clickasync Task LoadImageAsync(){// ...await DownloadRemoteDataAsync(...);// ...}async void Button_Click(...){await LoadImageAsync();UpdateView();}ClickMessagepumpTask ...DownloadRemoteDataAsyncTask ...LoadImageAsyncDownloadLoadImage
  13. 13. DEMOAsync UI app: re-entrancy and deadlock
  14. 14. DEMOAsync with cancelation
  15. 15. DEMOAsync console app
  16. 16. DEMOAsync unit tests
  17. 17. Source Code Caller ID
  18. 18. 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
  19. 19. 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));}
  20. 20. 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 =""){// …}
  21. 21. Breaking Changes
  22. 22. 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
  23. 23. Resources
  24. 24. 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
  25. 25. 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
  26. 26. 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
  27. 27. 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
  28. 28. Q&A
  29. 29. Patrocinador GoldPatrocinadores Silver
  30. 30. Media Partners
  31. 31. NOME DA APRESENTAÇÃONome (Nick no Fórum)25 DE MAIO @MICROSOFTThank You!Paulo Morgado (paulo.morgado)

×