In continuation to my earlier post about multithreading in .NET, I am writing about the ReaderWriterLock class which is one more method of thread synchronization.
The ReaderWriterLock is based on the fact that the Monitor locking (lock keyword in C#) doesnt really make any distinction whether the thread accessing the variable is [...]
I got an interesting problem by email recently where someone had asked me to solve the given below problem:-
A squad of robotic rovers are to be landed by NASA on a plateau on Mars.This plateau, which is curiously rectangular, must be navigated by therovers so that their on-board cameras can get a complete view of [...]
How often have you faced the irritating not responding screen while the application waits for the data that you requested for. The problem is not with bad code or a slow database, the problem with conventional applications is that all the code is executed on a single thread. i.e. whenever an operation is [...]
Events and Delegates are quite tied together in .NET, but there are differences in terms of usage. Events are implemented through delegates, but they are not quite interchangeable. The event keyword is an access modifier on the delegate which restricts its usage outside the class which it belongs to.
First the similarities. [...]
In the previous post we saw how anonymous methods can help reduce verbose delegate code. With C# 3.0, there was a new language feature introduced which further reduces the delegate code – Lambda expressions.
Lambda expressions use automatic type inference, which relieves you of explicitly declaring the type. Here is a simple example of lambda [...]
Anonymous methods are a convenient way of using delegates in .NET 2.0 and above. For e.g. if we use a delegate for a simple 2-3 line functionality, declaring a separate method and then passing the target to the delegate seems like overkill. Anonymous methods provide an easy way out, just declare the body [...]
I didn’t know this was possible until a few days back when a user asked about it on one of the MSDN forums. The query was on how to integrate Winforms and WPF i.e. how to display WPF user controls in Winform application. This feature can be extremely useful because some elements [...]
In the last post, we saw how the Message Loop in Windows works, with Windows constantly getting messages from the various events and dispatching them to correct window procedures. The Window Procedure then takes the message and it is responsible for handling the event. This handling of the message is done in the [...]
From an end user point of view, your application UI is the single most important part of your application. There may be a million lines of code in the business layer doing all sorts of magic, but try giving a unresponsive UI with it, and no guessing, how many takers you will find [...]
Delegates are not just function pointers with a fancy name, they are a huge leap over C++’s function pointers. Unlike unmanaged languages, .NET enforces type safety for its delegates. Good, because pointers are too scary to be tolerated in .NET’s perfect world, where there are no memory leaks and all a developer [...]