New Features in .NET Framework 4.0-Part02

Posted By  RRaveen On 22 Jun 2010 22:06:41
emailbookmarkadd commentsprint
No of Views:658
Bookmarked:0 times
Votes:0 times

Introduction

Today I would like to share with another great new feature in .NET Framework 4.0, the new features is how do we decide the current Operating System and Process version is 32 or 64 bits.

How to get the Operating System 32 or 64 bits

  •  Environment.Is64BitOperatingSystem

Determines whether the current operating system is a 64-bit operating system

How to use

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;using System.Data;namespace ConsoleApplication1
{class Program{static void Main(string[] args){if (Environment.Is64BitOperatingSystem){Console.WriteLine("This is 64 bit operating system");}else{Console.WriteLine("This is 32 bit operating system");}Console.ReadLine();}}}

 Output

This is 64 bit operating system

Note:I have run above code in windows 2003 Server.

How to know Process Bits

  • Environment.Is64BitProcess

Determines whether the current process is a 64-bit process.

How to use

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;using System.Data;namespace ConsoleApplication1
{class Program{static void Main(string[] args){if (Environment.Is64BitProcess){Console.WriteLine("This is 64 bit Process");}else{Console.WriteLine("This is 32 bit Process");}Console.ReadLine();}}}

 Output

This is 64 bit Process

 Note:I have run above code in windows 2003 server.

How to ternimate application with write log in event log

  • Environment.FailFast()

This method help to developers,Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and exception information in error reporting to Microsoft.

How to use

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;using System.Data;namespace ConsoleApplication1
{class Program{static void Main(string[] args){string causeOfFailure = "The unknown failure";try{Environment.FailFast(causeOfFailure);}finally{Console.WriteLine("This finally block will not be executed.");}}}}

 I hope this is help to you all, i will publish another tips about new features in .NET 4.0 soon.

Sign Up to vote for this article
Other popular Tips/Tricks
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top