background preloader

Principles of Software Development

Facebook Twitter

Processing Global Mouse and Keyboard Hooks in C# This article was posted in 2004 and updated in 2006 and 2008.

Processing Global Mouse and Keyboard Hooks in C#

During all this time until now I receive a lot of positive feedback and recommendations. There where also many useful contributions which where usually posted as code snippets in forum. Now instead of publishing yet another version on my own I decided to ask you all to actively participate. Beginners Guide To Threading In .NET Part 1 of n. Download demo project - 79.1 KB Introduction I am afraid to say that I am just one of those people that unless I am doing something, I am bored.

Beginners Guide To Threading In .NET Part 1 of n

So now that I finally feel I have learnt the basics of WPF, it is time to turn my attention to other matters. I have a long list of things that demand my attention such as WCF/WF/CLR via C# version 2 book, but I recently went for something (and got, but turned it down in the end) which required me to know a lot about threading. Whilst I consider myself to be pretty good with threading, I thought, yeah, I'm OK at threading, but I could always be better. Introduction to Multithreading in C# In working in New York and talking to programmers all over Wall Street, I've noticed a common thread of knowledge expected in most real time programming applications.

Introduction to Multithreading in C#

That knowledge is known as multithreading. As I have migrated around the programming world, and performed interviews on potential programming candidates, it never ceases to amaze me how little is known about multithreading or why or how threading is applied. In a series of excellent articles written by Vance Morrison, MSDN has tried to address this problem: (See the August Issue of MSDN, What every Developer Must Know about Multithreaded Apps, and the October issue Understand the Impact of Low-Lock Techniques in Multithreaded Apps. Dot Net Perls. Deploying Windows Applications with Visual Studio.NET, Part 2. Part 1 of this series explained the different ways of deploying a Windows application with the .NET Framework and identified when to use which deployment option.

Deploying Windows Applications with Visual Studio.NET, Part 2

It also demonstrated the configurations that are required to create an installer package. Part 2 examines the different editors that Visual Studio.NET provides and identifies the steps involved in using them. As Part 1 showed, you can access six types of editors in Visual Studio .NET deployment projects through the View | Editors menu. Create a Logger using the Trace Listener in C# When writing software for the commercial world it is crucial your application can log errors, be it to the database, or to a text file, or even to the Windows Event Log if necessary.

Create a Logger using the Trace Listener in C#

Value vs Reference Types in C# Joseph Albahari Introduction One area likely to cause confusion for those coming from a Java or VB6 background is the distinction between value types and reference types in C#.

Value vs Reference Types in C#

In particular, C# provides two types—class and struct, which are almost the same except that one is a reference type while the other is a value type. This article explores their essential differences, and the practical implications when programming in C#. Elegant Code Calling Non-Public Methods. A typical way for invoking a non-public method of a class is by using reflection.

Elegant Code Calling Non-Public Methods

This can come in handy in a number of cases. One typical scenario that comes to mind is when the designers of the .NET Framework or another 3rd party framework decided to bury a class or a method as internal while this could perfectly solve a problem (I just hate it when they do that). Invoking private methods is not considered a best practice in general, but there are cases where you have no other option than to fall back on using reflection. The following code snippet shows how one would typically accomplish that. public class Subject { private String DoSomething(String input) { return input; } } // Calling code var subject = new Subject(); var doSomething = typeof(Subject).GetMethod("DoSomething", BindingFlags.Instance | BindingFlags.NonPublic); var result = doSomething.Invoke(subject, new[] { "Hello Muppets" }); Console.WriteLine(result);

Creating a Basic Windows Service in C# Download source - 3.78 Kb Introduction Do a search some time on Google for Services and C#, and you'll come across a lot of ASP.NET references for web services.

Creating a Basic Windows Service in C#

Not very useful for a beginner looking for info on Windows Services! I've had this very problem, so I decided to do it myself, the old-fashioned way. C# Delegates, Anonymous Methods, and Lambda Expressions O My!. Free source code and programming help. Introduction Delegates, anonymous methods, and lambda expressions can be very confusing in .NET.

C# Delegates, Anonymous Methods, and Lambda Expressions O My!. Free source code and programming help

I think this is proven in code like the example below. Which one of the calls to First compiles? Which one returns the answer we are looking for; namely the Customer with the ID 5. The answer, incidentally, is that all six calls to First not only compile, but all find the correct customer and are functionally equivalent. Class Customer { public int ID { get; set; } public static bool Test(Customer x) { return x.ID == 5; } } ... The setup – What are delegates? C# Heap(ing) Vs Stack(ing) in .NET: Part I. Even though with the .NET framework we don't have to actively worry about memory management and garbage collection (GC), we still have to keep memory management and GC in mind in order to optimize the performance of our applications.

C# Heap(ing) Vs Stack(ing) in .NET: Part I

Also, having a basic understanding of how memory management works will help explain the behavior of the variables we work with in every program we write. In this article I'll cover the basics of the Stack and Heap, types of variables and why some variables work as they do. There are two places the .NET framework stores items in memory as your code executes. If you are not yet familiar with them, let me introduce you to the Stack and the Heap.

Learning C# by Example. The obligatory example for any language, using System ; public class HelloWorld { public static void Main ( string [] args ) { Console . Write ( "Hello World! " ); } } Raw CSharp compiler You can compile c# using the command line version and then run the new program by entering You can get Nant, a build tool like the old 'make', from . Reading Stuff. How to detect and avoid memory and resources leaks in .NET applications. By Fabrice Marguerie Despite what a lot of people believe, it's easy to introduce memory and resources leaks in .NET applications. The Garbage Collector, or GC for close friends, is not a magician who would completely relieve you from taking care of your memory and resources consumption. DateTime Format Examples. Settings.settings in Visual Studio. Settings.settings stores preferences on the disk.

Writing a setting to disk when a program exits and then reading it back when the program is started again is cumbersome. We can use instead the Settings.settings file. Intro There are some mechanisms for programmers to easily store settings on the disk, and access them in memory whenever needed. This helps improve speed of development and the feature set of programs. We get started through the Visual Studio C# development environment. Release COM object. Creating Tray Applications in .NET: A Practical Guide. It isn’t widely known that you can use both WPF and Winforms with VS2010 to create a system tray application in .NET. Michael gives you a practical guide, illustrated by an example that is so effective it can be put to immediate practical use.

HostSwitcher comes complete with source code and can be downloaded. This article is intended to be of interest to you in two different ways. If you just wish a practical guide on creating a system tray, then head straight for the section ‘The Tray Application Framework’, but if you’re more interested in actually using the application that we provide to illustrate the article, then click on ‘Introducing HostSwitcher‘. If you enjoy, and learn best by, following the whole process of how a particular system tray application was designed and built, then read on!

How to capture a Window as an Image and save it. Introduction. Parsing HTML in Microsoft C# Developer.com. The Parse and ParseHTML Classes If you only want to use the classes to parse HTML, you need not be concerned with the "Parse" class. The "Parse" class is used internally by the HTML parser to provide low-level support for attribute-value based files, such as HTML, SGML, XML, or even HTTP headers.

Some Cool Tips for .NET. FAQ : Windows Forms : Syncfusion. Current thread must be set to single thread apartment (STA) mode before OLE calls can be made - Soumitra Mondal's WebLog.