About

Tuesday 30 June 2015

Great .NET Framework 4.5 Features

1: async and await (code markers)
   
    async and await are pair keywords. You cannot use them in a standalone manner.
    async is marked on a method. This keyword is just an indicator saying that this method will have the await keyword.
    The await keyword marks the position from where the task should resume. So you will always find this keyword in conjunction with Task.

2: Zip facility (Zip compression)
   
    System.IO.Compression.FileSystem
    System.IO.Compression

    using System.IO.Compression;
        If you want to Zip files from a folder you can use the CreateFromDirectory function as shown below.
        ZipFile.CreateFromDirectory(@"D:\data",@"D:\data.zip");

    If you wish to unzip, you can use the ExtractToDirectory function as shown in the below code.
        ZipFile.ExtractToDirectory(@"D:\data.zip", @"D:\data\unzip");
       
3: Regex timeout (TimeOut)
    try
    {
      var regEx = new Regex(@”^(\d+)+$”, RegexOptions.Singleline, TimeSpan.FromSeconds(2));
      var match = regEx.Match(“123453109839109283090492309480329489812093809x”);
    }
    catch (RegexMatchTimeoutException ex)
    {
      Console.WriteLine(“Regex Timeout”);
    }
4: Profile optimization (Improved startup performance)
    An order to bring down this startup time, in .NET 4.5, we have something called “profile optimization”. Profile is nothing but a     simple file which has a list of methods which the application will need during startup. So when the application starts, a background     JIT runs and starts translating IL code for those methods into machine / native code.

    This background JIT compilation of startup methods happens across multiple processors thus minimizing the start up time further. Also     note you need to have a multicore box to implement profile optimization. In case you do not have a multicore box then this setting is ignored.
   
    using System.Runtime;

    // Call the Setprofilerroot and Startprofile method
    ProfileOptimization.SetProfileRoot(@"D:\ProfileFile");

    ProfileOptimization.StartProfile("ProfileFile");

5: Garbage collector (GC background cleanup)
    when the GC runs for cleanup, all the application threads are suspended. You can see in the above figure we have three application     threads running. We have two GCs running on separate threads. One GC thread for one logical processor. Now the application threads run     and do their work. Now as these application threads are performing their task they also create managed objects.

    At some point of time the background GC runs and starts clean up. When these background GCs start cleanup, they suspend all the     application threads. This makes the server/application less responsive for that moment.

    To overcome the above problem, server GC was introduced. In server GC there is one more thread created which runs in the background.     This thread works in the background and keeps cleaning generation 2 objects thus minimizing the load on the main GC thread. Due to     double GC threads running, the main application threads are less suspended, thus increasing application throughput. To enable server         GC, we need to use the gcServer XML tag and enable it to true.

    <configuration>
       <runtime>
          <gcServer enabled="true"/>
       </runtime>
    </configuration>
   
6: Set default culture to App Domain
    CultureInfo culture = CultureInfo.CreateSpecificCulture("fr-FR");
    CultureInfo.DefaultThreadCurrentCulture = culture;

7: Array support more than two gigabyte size

8: Unicode support for console

Referance : http://msdn.microsoft.com/en-us/library/ms171868.aspx
        http://www.codeproject.com/Articles/599756/Five-Great-NET-Framework-Features

.Net Framework Features From .Net 2.0,3.0,3.5,4.0 & 4.5

1. .Net Framework 2.0 Features

    ADO.NET 2.0
    SQL Server data provider (SqlClient)
    XML
    .NET Remoting
    ASP.NET 2.0

2. .Net Framework 3.0/3.5 Features

    Windows Presentation Foundation (WPF)
    Windows Communication Foundation (WCF)
    Windows Workflow Foundation (WWF)
    Windows Card Space (WCS)
    Core New Features and Improvements:

        Auto Implemented
        Implicit Typed local variable
        Implicitly Typed Arrays
        Anonymous Types
        Extension Methods (3.5 new feature)
        Object and Collection Initializers
        Lambda Expressions

3. .Net Framework 4.0 Features

    Application Compatibility and Deployment
    Core New Features and Improvements

        BigInteger and Complex Numbers
        Tuples
        Covariance and Contravariance
        Dynamic Language Runtime

    Managed Extensibility Framework
    Parallel Computing
    Networking
    Web
    Client
    Data
    Windows Communication Foundation
    Windows Workflow Foundation

4. .Net Framework 4.5 Features

    .NET for Windows Store Apps
    Portable Class Libraries
    Core New Features and Improvements
    Tools
    Parallel Computing
    Web
    Windows Presentation Foundation (WPF)
    Windows Communication Foundation (WCF)
    Windows Workflow Foundation (WF)

Referance Link : http://www.c-sharpcorner.com/uploadfile/sujit9923/net-framework-features-from-net-2-0-to-4-5/