Posted by Nicholas Brookins on 27 September, 2008 - 6 responses
// Threading and User Interfaces
When doing GUI development on Windows you must very careful what thread you access a form or control from. Hopefully most Windows Forms developers know this by now, but in the early versions of the framework it could be a sneaky issue. As of .NET 2.0 they were kind enough to immediately cause an exception when a control was accessed from the wrong thread - forcing you to deal with it now instead of trying to figure out why you randomly get exceptions like this 6 weeks after deploying your application: 
I wont delve much in to why this is necessary, there are plenty of explanations on the subject. The short story is that in .NET there is still a message loop that is running on the thread your form was run from, access from any other thread just isn’t thread-safe - you can’t use locking because it would block the user interface.
So let’s append the Async helper static class that we worked on in parts 1 and 2, giving it the ability to schedule tasks on the UI thread. This will go even further towards making an app cleaner and more maintainable.
UPDATE: This post is now an article on CodeProject.
More…
Posted by Nicholas Brookins on 24 September, 2008 - no responses
// The Code.
When we last were together, I spent entirely too long explaining the wrong and/or hard ways to start a quick asynchronous task in C#, and only gave a quick taste of what was to come with the Async helper class. This time I’ve got the source to back me up.
UPDATE: The first part of this series is now an article on CodeProject. Check it out and give it a vote for me.
// The main method: Async.Do(…);
Our Do() method is where most of the magic happens, although it is only 60 lines with generous comments. Sharp observers will notice a couple odd things: it is private, and it takes two different delegate parameters. There are several overloads, these in turn call this method passing one or the other delegate, depending on whether we need a return value. This cleans the caller’s code greatly.
Making one method that does the work keeps the important logic (and troubleshooting) in one place, but it is private as to not confuse the caller as to which delegate to use. More…
Posted by Nicholas Brookins on 17 September, 2008 - 2 responses
// Series Introduction
I’m a sucker for clean and beautifully groomed code. In my experience maintaining a large code base with few resources, it is in fact the only way to keep sanity and keep from sliding into a pit of spaghetti. I’ve been on a push to find areas of necessarily messy or repeated code and find ways to make them more elegant and maintainable - this is the first in a series* of small classes and helpers that I kick myself for not doing sooner.
UPDATE: This post is now an article on CodeProject.
// The Problem at Hand
In any reasonably large application there are a lot of times when you need to perform a quick task asynchronously. One use off-hand is application that saves a log or status report to file on start-up. The operation is slow in relative terms since it involves file I/O, and we don’t have to worry much about other code paths depending on it. Making it asynchronous will speed up our start time with no risk of side effects. More…
Posted by Nicholas Brookins on 12 August, 2008 - no responses
As for what it sucks, that would be system performance. It had been a long time since I’ve used Anti-Virus software on my Windows system, I hadn’t realized how bad the performance issue had gotten until I saw the benchmarks. I’d had more trouble with the Anti-Virus software itself than it could have possibly saved me, since well, it never found anything.
Part of the problem is that for quite a while now Spyware has been much more of a problem than conventional viruses, but the big boys like Norton and MacAfee have been slow to adjust and pick this up. Things are starting to change in that regard, but that leaves the issue of speed. More…
Posted by Nicholas Brookins on 8 July, 2008 - 4 responses
Visual SourceSafe (VSS). Those words make me shudder, and it’s been years since I have touched it. I was snapped back to the reality so many Microsoft-centric developers deal with when my friend Dave sent this: More…
Posted by Nicholas Brookins on 3 July, 2008 - 2 responses
It’s common in software that often the absolute basics get trumped by candy-coated interfaces and lists of features that mostly go unused (hmm.. MS office 2001-present?). In fact it used to be that the Operating System’s central role was actually memory and I/O management, can you imagine? It is an easy mistake to make. It is fun making new features; tail-wagging dogs that help you search or desktop gadgets that crash in new and interesting ways. The saying that “every program will eventually expand until it can read mail”, is pretty insightful. I swore off using Winamp on the dark day that it took over my video associations, but still couldn’t seem to handle ’shuffle’ correctly - it seemed at the time that every application was expanding until it could play movies.

There is way too much going on here.
More…
Posted by Nicholas Brookins on 9 June, 2008 - one response
As I mentioned in a previous installment, I had started the dreaded task of analyzing the source of the rdesktop project,
to see how I might best integrate it into ToastControl. For non-programmers, ‘having the source’ often seems to be 99% of the solution, when in fact it can be closer to 10%, or I could argue even a liability sometimes. While it may seem like having the plans to a building - I don’t know of many architects that use their own system of measurement for dimensions (variable names), re-define the standard types of rooms and what they do (functions / methods), or hopefully none that use recursion (Frank Lloyd Wright meets M.C. Escher?).
The possible issues are many. First of all, rdesktop is a great piece of software and I have great respect for it, and owe thanks to the author, Matt Chapman. That could be part of the problem - what if this guy is a genius, and I’m not able to even comprehend his masterpiece?1 I risk not being able to figure it out, damaging my fragile binary ego. Even worse would be that he thinks he’s a genius, but falls somewhat short of the mark - creating an obtuse and abstruse monstrosity that seeks to reinvent software development at it’s core (you know, I’ll bet I can do better than this silly Boolean stuff…). For examples of this, look no further than the Daily WTF. More…
Posted by Nicholas Brookins on 4 June, 2008 - 4 responses
I’ve managed to plug away at ToastControl a bit over the last couple weeks, and have some items to report.
Decisions decided

- - I’m going to use Python. I wanted to use a dynamic language that would be flexible. The heavy lifting is done by the plug-ins like Rdesktop / mstsc and VNC anyway, written in C - the surrounding application doesn’t need tons of speed. Ruby was a contender, but Python seems much more suited to cross-platform thick-client apps like this, at least at the moment.
More…
Posted by Nicholas Brookins on 2 June, 2008 - no responses
I recall first using Windows 3.1 and thinking it was pretty cool - but man they needed to do somthing about the file manager. I was a DOS user, accustomed to xcopy and the superb XTree
and XTreeGold applications. I’m not asking for too much - just the basic abilities xcopy offers, like continuation after an error, copying files after a newer date, and the like. You know though, Windows 95 was just a few years around the corner - I was sure they would fix the basics by then.
Windows 95 didn’t do much for file management, other than eliminate the MDI interface we were just getting used to. In fact, the notoriously bad progress message during file operations just made things worse - it wouldn’t even tell us how fast the bytes were moving. I set to work on a shell extension to add some of the xcopy goodness to Windows Explorer. More…
Posted by Nicholas Brookins on 22 May, 2008 - no responses
There are many ways to control a PC remotely and a plethora of programs for each option. However as an IT professional for the last gazillion years, I’ve never been truly happy with them, and often resort to the command line for VNC and Remote Desktop (rdp / mstsc / terminal services). Nothing wrong with that - but it is a pain to manage multiple hosts, and it seems I’m always scrolling through the terminal history to find the one I need.
Windows Server 2003 shipped with the Remote Desktops MMC snap-in - available in Administrative Tools or by running ‘tsmmc.msc’. It gives you a sidebar for managing multiple hosts, but that’s about where it ends. It is not particularly stable, is somewhat cumbersome, and doesn’t even allow you to reorder connections, let alone organize them in any way.
More…