News In The Net40
Upcoming SlideShare
Loading in...5
×
 

News In The Net40

on

  • 1,598 views

These are the slides for the "News in Net4.0" presentation from 20th of feb 2010 in Iasi at Ramada (details at codecamp.ro)

These are the slides for the "News in Net4.0" presentation from 20th of feb 2010 in Iasi at Ramada (details at codecamp.ro)

Statistics

Views

Total Views
1,598
Views on SlideShare
1,571
Embed Views
27

Actions

Likes
0
Downloads
13
Comments
0

3 Embeds 27

http://www.linkedin.com 17
http://www.slideshare.net 5
https://www.linkedin.com 5

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

News In The Net40 News In The Net40 Presentation Transcript

  • News in C# and NET 4.0
    Iaşi, 20 februarie 2010
    Florin Cardaşim, www.rms.ro
  • Agenda
  • C# 4 named and default params
    Named method parameters
    Default method parameter values
  • C# 4 & DLR
    Interop via Dynamic Language Runtime
    Dynamically-Typed
    Ruby
    Python
    Statically-Typed
    VB
    Dynamic Language Runtime
    C#
    Common Language Runtime
  • C# 4 & the DLR: dynamic
    Interop with dynamic languages like Ruby, Python
    Interop with COM
  • C# 4 – DLR Support: dynamic
    Interop always comes
    with a performance cost,
    so do not use dynamic if
    you don’t really need it
  • C# 4 – DLR Support: dynamic
    Don’t abuse dynamic in C# because you loose:
    • compile time type checking and intellisense
    • runtime performance
    Use dynamic where appropriate
  • C# 4 & the DLR
    System.Numerics.BigInteger
    System.Numerics.Complex
    System.Tuples
    Tuple.Create(1,2,3,4,5,6,7,8) - maximum 8 members!!
    Property names are Item1, Item2, .., Item8 – ugly!
    Can be used as method params and return values
    Can be inherited
    Can be extended by extension methods
    Specifically useful in F#
    I’ll probably NOT use it in C# 
    http://msdn.microsoft.com/en-us/vcsharp/ee957397.aspx
  • Generics Covariance & Contravariance
  • Generics Co&Contravariance
    http://msdn.microsoft.com/en-us/library/dd799517(VS.100).aspx
  • Exceptions Management
    This code is bad!
    WHY?!!!
  • Exceptions Management
    • What is the problem?
    (Exception ex) might be a Corrupted State Exception (CSE) , like Access Violation, Invalid Memory, Divide By Zero, Stack Overflow
    • What to do if Exception is CSE?
    Your process and data are in danger. ABORT.
    Are other actions possible?
    • What is CLR 4.0 doing?
    CLR 4.0 will NOT deliver CSEs to our code by default
    catch(Exception ex) will NOT catch the CSE
    Your process will ABORT
  • Exceptions Management
    For backwards compatibility use
    Or at application level
  • Exceptions Management
    A bit of history:
    • CLR1.1: unhandled exceptions (on secondary threads) will NOT abort process
    • CLR 2.0: unhandled exception on secondary will ABORT the process
    • CLR 4.0: CSEs not handled by catch(Exception), process will ABORT
    Conclusions:
    • Do not handle exceptions if you don’t know how
    • ABORT is better than a corrupted process
  • Exceptions Management
    Conclusions:
    • Only catch exceptions that you can handle
    • ABORT is better than a corrupted process
    • If your process ABORTs than there is a bug somewhere. GO FIX IT!
    • If you really need CSEs in your code use:
    [HandleProcessCorruptedStateExceptions]
    Or
    legacyCorruptedStateExceptionsPolicy enabled="true“
  • Net 4.0 application dump debugging
    When do we need a dump
    Crash, hang, performance analysis etc
    How to collect a dump
    adplus.vbs, DebugDiag etc
    Task Manager/Create Dump File
    VS2010/Debug/Save Dump As…
    How to analyze the dump
    Until now windbgonly for native apps
    Now VS2010 knows to debug .NET 4.0 app dump
  • Net 4.0 dump debugging
    Dump debugging with WinDbg
  • Net 4.0 dump debugging
  • Code Contracts
    Until CLR 4.0
    • Code comments
    • Debug.Assert, Argument validation: if-then-throw
    • Unit tests?
    In CLR 4.0 we have System.Diagnostics.Contracts
    • Preconditions
    • Required before a method can run
    • Postconditions
    • True at the completion of a method
    • Object invariants
    • Conditions that are always true
  • App Domain Profiling
    • A host application may profile the activity of the hosted applications (for example add-ins) and attempt to restart it if takes too many resources
    DEMO: “MonitoringIsEnabled”
  • Enhanced GC
    Concurrent GC
    • Can NOT do Gen0, Gen1 GC (ephemeral segment) at the same time with Gen2 GC
  • Enhanced GC
    Backgound GC
    • CAN do a Gen0, Gen1 GC (ephemeral segment) while doing Gen2 GC
  • Enhanced GC
    Concurrent GC
    Background GC
    Latency during application execution
  • Parallel Computing in .NET 4
    Why should we care about parallel computing?
    Because we care about application performance
    Because our CPUs/cores are not used at full capacity
    System.Threading
    • Barrier
    • CountdownEvent
    Parallel Extensions
    • Parallel LINQ (PLINQ)
    • Task Parallel Library (TPL)
    • Coordination Data Structures – System.Colllectiions.Concurrent
    Unified cancellation model
    • CancellationTokenSource, CancellationToken
  • Demo: System.Threading, UCM
    System.Threading
    • Barrier
    • CountdownEvent
    Parallel Extensions
    • Parallel LINQ (PLINQ)
    • Task Parallel Library (TPL)
    • Coordination Data Structures (CDS)
    Unified cancellation model
    • CancellationTokenSource, CancellationToken
  • Demo: Parallel LINQ
    System.Threading
    • Barrier
    • CountdownEvent
    Parallel Extensions
    • Parallel LINQ (PLINQ)
    • Task Parallel Library (TPL)
    • Coordination Data Structures (CDS)
    Unified cancellation model
    • CancellationTokenSource, CancellationToken
  • Demo: Task Parallel Library
    System.Threading
    • Barrier
    • CountdownEvent
    Parallel Extensions
    • Parallel LINQ (PLINQ)
    • Task Parallel Library (TPL)
    • Coordination Data Structures (CDS)
    Unified cancellation model
    • CancellationTokenSource, CancellationToken
  • References
    MSDN
    MSDN Magazine
    Channel9
    VS2010 Training Kit
    Msdn.blogs.com/Tess
  • Please fill the evaluation form !!!
    Thank you very much
    Florin Cardasim
    • florin.cardasim@rms.ro
    • www.rms.ro
    • www.codecamp.ro
    • www.Twitter.com/cardasim