31
What’s New in .Net 4.5 Intro into new Features

What's New in .Net 4.5

Embed Size (px)

DESCRIPTION

My small PPP

Citation preview

  • 1.Intro into new Features

2. Improvements to WeakReferences ArraySegment Streams ReadOnlyDictionary Compression Bigger than 2GB Objects 3. Background Server GC Shorter pauses when doing Gen2 Collections(Server GC) Scalable Marking for full blocking GCsLarge Object Heap Allocation Improvements Better use of free space on LOH Balancing the LOH allocations across processors (Server only) Up to 2GB Large Array on 32bit and more then 2GB on 64bitSystems 4. public class SomeClass {public void DownloadStringAsync() {WebClient wc1 = new WebClient();wc1.DownloadStringCompleted += (sender, e) => {string res = e.Result;};wc1.DownloadStringAsync(new Uri("http://www.SomeWeb.../"));}} 5. public class SomeClass {public async void DownloadStringAsync() {WebClient web = new WebClient();string res = await web.DownloadStringAsync("www.SomeWeb...");}} 6. Two keywords for asynchronous programming:The method signature includes an Async or asyncmodifier.The name of an async method, by convention, endswith an "Async" suffix.The return type is one of the following types: Task if the method has a return statement in which the operand has type TResult. Task if the method has no return statement or has a return statement with no operand. Void (a Sub in Visual Basic) if its an async event handler. 7. The method usually includes at least one awaitexpression, which marks a point where themethod cant continue until the awaitedasynchronous operation is complete.In the meantime, the method is suspended, andcontrol returns to the methods caller. 8. These features add a task-based model forperforming asynchronous operations. To usethis new model, use the asynchronous methodsin the I/O classes. Asynchronous operations enable you to performresource-intensive I/O operations withoutblocking the main thread. This performance consideration is particularlyimportant in a Windows Metro style app ordesktop app where a time-consuming streamoperation can block the UI thread and make yourapp appear as if it is not working. 9. async void DisplayUserInfo(string userName) {var image = FetchUserPictureAsync(userName);var address = FetchUserAddressAsync(userName);var phone = FetchUserPhoneAsync(userName);await Task.WhenAll(image, address, phone);DisplayUser(image.Result, address.Result,phone.Result);} Client UI Code Easy to write client UI code that doesnt block Business logic Easy to write code that fetches data from multiple sources in parallel Server code Better scalability no need to have a thread per request. New APIs in BCL, ASP.NET, ADO.NET, WCF, XML, WPF 10. Combinators Task.WhenAll, Task.WhenAny Timer integration Task.Delay(TimeSpan), CancellationTokenSource.CancelAfter(TimeSpan) Task scheduling ConcurrentExclusiveSchedulerPair Fine-grained control DenyChildAttach, HideScheduler, LazyCancellation, EnumerablePartitionerOptions ThreadLocal.Values PERFORMANCE (its just faster) 11. The Managed Extensibility Framework (MEF)provides the following new features: Support for generic types. Convention-based programming model that enables to create parts based on naming conventions rather than attributes. Multiple scopes. A subset of MEF that you can use when you create Metro style apps. This subset is available as a downloadable package from the NuGet Gallery. 12. All your objects are MEF now Generics POCO Explicit Wiring (wire specific MEF parts the way YOUwant) MEF problems are easy to diagnose Break on First Chance Exceptions Visualize the exception Fix your problem! 13. Resource File Generator (Resgen.exe) - enables you to create a .resw file for use inWindows apps from a .resources file embedded in a.NET Framework assembly.Managed Profile Guided Optimization(Mpgo.exe) - enables you to improve application startup time,memory utilization (working set size), andthroughput by optimizing native image assemblies.The command-line tool generates profile data fornative image application assemblies. 14. Improved performance, increased control,improved support for asynchronousprogramming, a new dataflow library, andimproved support for parallel debugging andperformance analysis.The performance of TPL, such that just byupgrading to .NET 4, important workloads willjust get faster, with no code changes or evenrecompilation required.More queries in .NET 4.5 will now automaticallyrun in parallel. A prime example of this is a 15. ASP .NET 4.5 includes the following newfeatures: Support for new HTML5 form types. Support for model binders in Web Forms. These let you bind data controls directly to data-access methods, and automatically convert user input to and from .NET Framework data types. Support for unobtrusive JavaScript in client-side validation scripts. Improved handling of client script through bundling and minification for improved page performance. Integrated encoding routines from the AntiXSS library 16. Support for WebSockets protocol. Support for reading and writing HTTP requests and responses asynchronously. Support for asynchronous modules and handlers. Support for content distribution network (CDN) fallback in the ScriptManager control. 17. The ASP.NET Web API takes the best features from WCF WebAPI and merges them with the best features from MVC.The integrated stack supports the followingfeatures: 18. From 353,5 KB + multiple call overhead+84% improvement To 59.83 KB + one call overhead 19. Twoways to run ASP.NET Start app, keep it running Start when a request comes in (e.g. Hosters) 35% faster cold start Multi-core JIT Windows Server 8 pre-fetch option Working set improvements 20. Even more support for SQL Server 20082012 Null bit compression for sparse columns Support for new Denali features Support for High Availability Just set the correct keyword in the connection string Fast Failover across multiple subnets Support for new Spatial Types (GIS) More good stuff Passwords encrypted in memory Async support 21. Spatial data support Table valued functions Stored procs with multiple result sets Automatic compiled LINQ queries Query optimization 22. Runs on its own cadence so more features &improvements more often Enum support throughout Support for localdb Designer improvements!(Multiple diagrams per model) 23. Improve Developer Productivity Enums Migrations Batch Sproc Import Designer highlighting and coloring EnableSQL Server and Azure Features Spatial (Geometry and Geography) Table-valued functions Sprocs with multiple result sets Increase Enterprise Readiness Multiple diagrams per model TPT query optimizations Automatic compiled LINQ queries 24. The .NET Framework 4.5 provides a new programminginterface for HTTP applications.New System.Net.Http and System.Net.Http.Headers namespaces.A new programming interface for accepting and interactingwith a WebSocket connection by using theexisting HttpListener and related classesThe .NET Framework 4.5 includes the following networkingimprovements: RFC-compliant URI support. For more information,see Uri and related classes. Support for Internationalized Domain Name (IDN) parsing. 25. Simplified Generated Configuration Files New Transport Default Values XmlDictionaryReaderQuotas Contract-First Development WCF Configuration Validation XML Editor Tooltips Configuration Intellisense ASP.NET Compatibility Mode Default Changed Simplifying Exposing an Endpoint Over HTTPS withIIS Generating a Single WSDL Document Streaming Improvements Async Streaming 26. WebSocket Support ChannelFactory Caching Scalable modern communication stack Interoperable UDP multi-cast channel TCP support for high-density scenarios (partialtrust) Async Improved streaming support Continued commitment to simplicity Further config simplification, making WCFthrottles/quotas smarter & work for you by default! Better manageability via rich ETW & e2e tracing 27. The New Ribbon Controls Validating data asynchronously and synchronously Data Binding Changes Improved performance when displaying large sets ofgrouped data Delay property binding Accessing collections on non-UI Threads Binding to static properties And more! Markup extensions for events ItemsControl Improvements New features for the VirtualizingPanel Improved Weak Reference Mechanism 28. OOMat 7min 24.5s 2.3s 29. .NET 4.5 is an in-place update that helps us makesure it is highly compatible. .NET 4.5 makes it easy and natural to write Metrostyle apps using C# and VB .NET 4.5 makes your apps run faster: Faster ASP.NETstartup, fewer pauses due to Server GCs, and greatsupport for Asynchronous programming .NET 4.5 gives you easy, modern access to your data,with support for Entity Framework Code First, andrecent SQL Server features, and WebSockets .NET 4.5 addresses the top developer requests inWPF, Workflow, BCL, MEF, and ASP.NET