Asynchronous Delegates

August 27, 2008

Every delegate has the inherent ability to be called asynchronously. When a delegate is defined, the compiler creates a new class inheriting from MultiCastDelegate and synthesizes a constructor and 3 methods: The first, and most well known, is Invoke, that accepts the arguments defined in the delegate signature. This is the method called when the delegate is "invoked". Assuming the following: delegate int BinaryDelegate(int a, int b, out bool overflow); An instance of the delegate can be invoked like so: static int InvokeOperation(BinaryDelegate op, int a, int b, out bool overflow) { if(op != null) ...
no comments

What can we expect in C# 4.0?

August 19, 2008

Actually, I have no idea... but here are my suggestions for new features that I think are worth it: 1. Generic Operators Currently, operators do not work on generic types without some base class constraint that defines those operators. For instance, the following code does not compile:public static T Sum<T>(IEnumerable<T> data) where T : struct { T sum = new T(); foreach(T i in data) sum += i; return sum; } The reason is that the compiler and the CLR cannot insure all types have the + operator. This is...
one comment

CLR Explorer v 0.2

August 17, 2008

Here's an update to the CLR Explorer tool. Improvements in this version are: Added a "Types" node under an assembly node. Lists all the types with name, namespace, type (class, interface, struct, enum) and visibility (public or internal). Simple sorting is supported. Right-clicking on a thread and selecting "Call Stack..." shows the call stack of that thread (only if it's a managed thread). Pressing Tab navigates from the tree view to the list view and back... Any comments or suggestions are welcome.
one comment

CLR Explorer Tool

August 10, 2008

In the last few days I created the first version of a tool I call "CLR Explorer". This tool allows viewing live CLR-enabled processes, showing the AppDomains, threads and assemblies in those processes. The application is similar in look to Windows Explorer, with a tree-like view on the left and a list view on the right. Here's a screen shot: The tool works by utilizing the native debug interfaces the CLR provides, namely ICorDebug and its derivatives, such as ICorDebugProcess and the like. These are the basis of a CLR based debugger. I have a started an...

To Ngen or Not to Ngen

August 6, 2008

As we all know, the CLR JIT compiles the IL code to the native platform upon first invocation of a method in the current run. When people hear of the Ngen.Exe tool, that allows compilation to native code - they usually think it's a great idea. So why not use it? No need to JIT compile - the application should start faster. Are there any downsides? The main downside to using Ngen is the lack of runtime optimizations. Ngen must select some target CPU and compile against it. When the CLR JIT compiles a method, it can use actual...