O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

As novidades do C# 5.0

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
What's new in c# 5.0   net ponto
What's new in c# 5.0 net ponto
Carregando em…3
×

Confira estes a seguir

1 de 31 Anúncio

As novidades do C# 5.0

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

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

Anúncio
Anúncio

Mais Conteúdo rRelacionado

Diapositivos para si (19)

Semelhante a As novidades do C# 5.0 (20)

Anúncio

Mais recentes (20)

Anúncio

As novidades do C# 5.0

  1. 1. NOME DA APRESENTAÇÃO Nome (Nick no Fórum) 25 DE MAIO @MICROSOFT What’s New In C# 5.0 Paulo Morgado (paulo.morgado)
  2. 2. Paulo Morgado CodePlex Revista PROGRAMAR
  3. 3. A Language For Each Generation # 3
  4. 4. The Evolution Of C# # 4 C# 1.0 C# 2.0 C# 3.0 C# 4.0 C# 5.0 Managed Generics LINQ Dynamic Async
  5. 5. The Evolution Of C# # 5 C# 1.0 C# 2.0 C# 3.0 C# 4.0 C# 5.0 Managed Generics LINQ Dynamic Async please wait for the next slide clicking won’t make it come any faster
  6. 6. DEMO Synchronous UI Application
  7. 7. Introducing Async
  8. 8. Introducing Async - Yesterday # 8 Click void LoadImage() { // ... LoadLocalData(...); // ... } void Button_Click(...) { LoadImage(); UpdateView(); } Click Messagepump
  9. 9. Introducing Async - Today # 9 Click void LoadImage() { // ... DownloadRemoteData(...); // ... } void Button_Click(...) { LoadImage(); UpdateView(); } Click Messagepump
  10. 10. DEMO Add the async & await keywords
  11. 11. Introducing Async async void Button_Click(...) { await LoadImageAsync(); UpdateView(); } async Task LoadImageAsync() { // ... await DownloadRemoteDataAsync(...); // ... } Messagepump void LoadImage() { // ... DownloadRemoteData(...); // ... } void Button_Click(...) { LoadImage(); UpdateView(); } Click
  12. 12. Introducing Async # 12 Click async Task LoadImageAsync() { // ... await DownloadRemoteDataAsync(...); // ... } async void Button_Click(...) { await LoadImageAsync(); UpdateView(); } Click Messagepump Task ... DownloadRemoteDataAsync Task ... LoadImageAsync Download LoadImage
  13. 13. DEMO Async UI app: re-entrancy and deadlock
  14. 14. DEMO Async with cancelation
  15. 15. DEMO Async console app
  16. 16. DEMO Async 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 that contains the caller. This is the file path at the time of compile. • http://msdn.microsoft.com/library/system.runtime.compilerservices.callerfilepathattribute.aspx • CallerLineNumberAttribute • Allows you to obtain the line number in the source file at which 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 the caller to the method. • http://msdn.microsoft.com/library/system.runtime.compilerservices.callermembernameattribute.aspx # 18
  19. 19. Source Code Caller ID - Examples # 19 static 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 # 20 private 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 lambda expression that’s contained in the body of the loop. • You can use the iteration variable of a foreach statement in a LINQ expression that’s contained in the body of the loop. • Overload resolution has been improved for calls that use named arguments to access methods that contain params parameters. • Overload resolution is improved for calls where the algorithm must choose between a Func<object> parameter and a Func parameter that has a different type parameter (e.g., string or int?) for a Func<dynamic> argument. • Side effects from named and positional arguments in a method call now occur 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 Lippert's Blog • http://ericlippert.com/ • http://blogs.msdn.com/b/ericlippert/archive/tags/c_2300_+5-0/async/ # 25
  26. 26. Resources • Lucian Wischik's 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?Us erName=PauloMorgado • http://www.slideshare.net/PauloJorgeMorgado # 27
  28. 28. Q&A
  29. 29. Patrocinador Gold Patrocinadores Silver
  30. 30. Media Partners
  31. 31. NOME DA APRESENTAÇÃO Nome (Nick no Fórum) 25 DE MAIO @MICROSOFT Thank You! Paulo Morgado (paulo.morgado)

×