Browse by Tags
All Tags »
.NET (
RSS)
One of the well-known pitfalls of using events, is the holding of the subscriber instance by the publisher (if connecting to a delegate holding an instance method). If the subscriber forgets to unsubscribe, the instance cannot be garbage collected because the publisher holds a reference to it. Worse yet, the subscriber continues to receive event notifications even though it’s not interested. One way to deal with this is presented in Jeffrey Richter’s book “CLR via C#” . The idea is based on a custom...
It’s something I came across, which seems like a bug to me. A WPF element can use a style automatically if the style uses the TargetType property set to the type of that element and there is no x:Key value. That is, there is no need for a (e.g. textual) key (the type is the key), and there is no need to specify a Style property for elements of that type. For some reason, the Separator type, commonly found in menus and toolbars, does not respect it, and requires an explicit Style setting with an appropriate...
Sometimes we need some new functionality from a basic control. One way to go about it is to create a custom control and add that functionality. However, sometimes creating a new control is an overkill, especially when no new behaviour is actually needed. Perhaps some new way of presenting or drawing the control is all that’s needed. The problem is that we may want more properties on the control, but we don’t want or need to actually extend it (i.e. derive from it). For example, suppose we want to...
Yesterday, I delivered a session titled “What’s new in C# 4.0?” after a session by Guy Burstein on “First look at Visual Studio 2010” . Thank you all for attending. I apologise for not using all the feedbacks to select winners for the books – sorry, guys! I’ll pay attention next time (probably lack of food). Some notes that came up during the session: 1. The misbehavior on the DynamicXmlElement class was due to a small oversight: I wrote this code when only one element existed: case 1: ...
When creating threads, we don’t usually think of its stack size. In the native world, the CreateThread function accepts a stack size (second argument) which we usually pass as 0. In the managed world, the Thread class exposes a pair of constructors expecting a stack size argument (which I was reminded by a comment). Why is this important? Creating threads has its costs. This is not only the added work the Windows scheduler must undertake or the data structures that must be allocated in the kernel...
For all those WinDbg + SOS/SOSEX lovers, a new version of SOSEX was published, which includes some new commands and enhancements to existing ones. Here’s a brief description of each command. More info can be found in the readme file and using !help <command> inside WinDbg. dlk (no parameters) ...
In the last few months, my Windows captions look something like this: The caption buttons are not square. Someone asked me how I did it… Well, Windows UI (Personalize…, etc.) allows changing the size of the caption buttons, but the width must be the same as the height. To make the caption buttons rectangular, one needs to call the SystemParametersInfo native API. Here’s some C++ code that does what you see here (width = 3 times height): NONCLIENTMETRICS metrics = { sizeof ( metrics ) }; :: SystemParametersInfo...
I’ll be teaching next week (starting from the 16th) a five day course (split) entitled “The C# 3.0 programming language” on .NET and C# fundamentals. On the 18th of this month, I’ll do an open house at Microsoft on C# 3.0 and LINQ (same thing I did a few months back at Air Force house, so if you were there, no need to come again – unless you really like the food). You can register here . On March 1st, I’ll be teaching my Windows Internals class (for developers) on the (obviously) internals of the...
Recently I was searching for a mathematics library for use in .NET applications and I stumbled upon Math.Net , an open source math library that includes two main components: The first, called Iridium , deals with the basics: numbers, vectors, matrices and the like. The second, Neodym , is a digital signal processing toolkit, containing things like various filters, modulators, time-frequency processing tools and the like. Worth checking out if you’re in the math business.
I mentioned in the past the Natural Language Processing (NLP) library Proxeme Antelope , based on the .NET 2.0 framework. This library has been recently updated (version 0.8.6) and includes multithreading support, some API redesign for increased consistency and other enhancements. Download and experiment!
In my previous report , I forgot to mention one more significant product update: Office. The next version of Office (“Office 14”) will have an online version, complete with the famous Ribbon and all major editing capabilities. In addition, synchronization services will allow nice, seamless sync between an online and offline versions, including the ability to open the same file by multiple users for editing with automatic or manual updates. On with day 3! Today’s keynote was by Rick Rashid, the head...
Yesterday I gave a presentation for the VB user group about Generics (yes, Generics, not some fancy WPF/WCF/Silverlight/Entity/etc.). It was fun learning Visual Basic... IVBUG Generics Presentation + Demos
In the CLR world, there is no real difference between a DLL and an EXE: Both are assemblies, both contain metadata and code, etc. The only real difference is that an EXE has an entry point ("Main"). Because of this, a single OS process can host multiple executables and run them concurrently in separate AppDomains. From Windows' perspective there is only one process. But multiple .NET applications may be running inside. To do this, the host application can create additional AppDomains...
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...
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...
More Posts
Next page »