Saturday, February 07, 2004

BackgroundWorker in Whidbey

As I have seen today in Whidbey there are a lot of new components and controls for WinForms programming. A cool new component is the System.ComponentModel.BackgroundWorker component. With this component you can initialize a new worker thread and execute them async. [Klaus Aschenbrenner]

The BackgroundWorker has several other cool features:

  • BackgroundWorker.CancelAsync() and BackgroundWorker.CancellationPending - allow you to notify the worker thread that you want to cancel the job.
  • BackgroundWorker.ReportProgress() and BackgroundWorker.ProgressChanged - the worker thread can call ReportProgress() which fires the ProgressChanged event. This is handy for updating progress bars etc. The ProgressChanged event handler runs on the original thread not the worker thread.
  • BackgroundWorker.RunWorkerCompleted - this event is fired when the worker thread is finished. It reports the final status of the worker thread, any exceptions that were thrown, and any resulting data from the worker thread. The RunWorkerCompleted event handler also runs on the original thread.

Since the only code that runs on the worker thread is the DoWork event handler you only have to worry about thread safety there. Since the BackgroundWorker provides for progress reporting, returning results, canceling, catching exceptions, etc. you can focus on the business logic in the DoWork event handler.

The pattern that the BackgroundWorker defines is used throughout Whidbey. The new Web Service Proxy classes will use it so Web Service calls will be asynchronous by default. The new Asynchronous ADO.NET functionality uses the BackgroundWorker pattern too.

2/7/2004 10:35:24 PM (Central Standard Time, UTC-06:00)  #    Trackback

RSS Bandit is amazing

I've been a Bloglines user for almost a year. I needed a portable aggregator because I use several different computers. Then a few months ago I got a TabletPC. Now portability isn't as critical since I always have my Tablet with me. I stayed with Bloglines though because none of the client-side aggregators I tried before worked for me.

I just downloaded the latest version RSS Bandit. I love it. It is much more polished than it was the last time I tried it. Combine that with the dasBlog integration and the upcoming SIAM support and I'm in hog heaven. Thanks Dare, Torsten, and everyone else that helped make RssBandit what it is.

2/7/2004 8:57:40 PM (Central Standard Time, UTC-06:00)  #    Trackback

Give us a merge module!

I swear if I have to deal with one more flaky-doesn't play well with others-piece of shit redistributable installer, I will find the dolts responsible and beat them about the head and shoulders with a fucking cheese grater!!!

I'm currently being tortured by Sun's JRE installer but Microsoft is just as guilty.

2/7/2004 6:09:29 AM (Central Standard Time, UTC-06:00)  #    Trackback

 Wednesday, February 04, 2004

Compiling the VNC Client with J#

Today a coworker of mine discovered that you can compile the 1.2.9 Java VNC client with J#. Here's the J# project to prove it.

2/4/2004 10:15:08 PM (Central Standard Time, UTC-06:00)  #    Trackback

Registering .NET Assemblies during installation

Sometimes setting the Register property to vsdrpCOM or vsdraCOM in a Visual Studio .NET setup & deployment project doesn't work. For some reason your assembly isn't registered. When this happens use a Custom Action to register your assembly manually. Ian Turner describes how in a post to the Microsoft newsgroups.

2/4/2004 9:20:04 PM (Central Standard Time, UTC-06:00)  #    Trackback

 Tuesday, February 03, 2004

ClickOnce Activation Errors on Windows 2003

ClickOnce errors are less than helpful in the PDC build of Whidbey. Shawn Farkas says that will improve in future builds. I'm looking forward to see what they come up with.

In the mean time if you are trying to publish your ClickOnce application to a Windows 2003 server and you are having problems check the following:

  • Make sure anonymous users can access the site and the files contained therein. By default Windows 2003 doesn't enable anonymous access to new web sites. The anonymous user - IUSER* - doesn't have access to the files on an NTFS volume by default either.
  • IIS on Windows 2003 doesn't serve file types it doesn't know about. Make sure you have the .deploy and .manifest extensions mapped to the "application/deployment" mime type.
  • If you are using Virtual PC make sure your virtual network adapter is mapped to the correct real network adaptor. I had my virtual adapter mapped to my wired Ethernet adapter but I was connected to my wireless network. For reasons I don't fully understand, ClickOnce failed until I mapped my virtual adapter to my wireless adapter.

For more information see Duncan Mackenzie's excellent Introducing Client Application Deployment with "ClickOnce" article.

Update: Apparently it is a well known issue that ClickOnce in the PDC build of Whidbey does not work when you are offline. You'll know this is your problem because you'll see "Download failed because the machine is offline." in your deployment log (see Shawn's post for the location of the log). If you have Whidbey installed on a Virtual PC machine you can easily work around this problem by setting your virtual network adapter to "Local only" or "Shared networking (NAT)". Then ClickOnce will work even when your host machine is disconnected.

2/3/2004 9:45:06 PM (Central Standard Time, UTC-06:00)  #    Trackback

Web site performance measurement

Tracert has a great free service - Speed-Meter - that will help you identify performance problems with your web sites. They also have a for-pay performance monitoring service that will let you monitor the performance of your site on an ongoing basis.

2/3/2004 11:56:22 AM (Central Standard Time, UTC-06:00)  #    Trackback

 Monday, February 02, 2004

Guilty as charged

Of the 200+ feeds to which I subscribe, fifty 35 seem not to support either of these two bandwidth-saving techniques, which means they're probably getting battered unnecessarily by feedreaders. [Jon Udell]

I installed an older version of dasBlog that doesn't support ETag or conditional GET (If-Modified-Since). I'm going to upgrade to the latest version of dasBlog later tonight. It supports both ETag and conditional GET.

Note to self: the latest version of dasBlog only lives at GotDotNet.

Update: My feed now supports ETag & conditional GET.

2/2/2004 8:39:08 PM (Central Standard Time, UTC-06:00)  #    Trackback

"Best Practices"?

Is there something I'm missing here? Why call Close() and Dispose()?

If there isn't any good reason, then I'm wondering just how much the authors of the book could really know about "best practices." Is it a best practice to include unnecessary code just because you've never bothered to look at how Dispose() works? [Rory Blyth]

I recently saw someone add something like the following in a demo:

SqlConnection connection = new SqlConnection(...);
connection.Open();
// code that uses the connection...
connection.Close();

He then said that in production code he should really protect that in a try...catch but it was easier and cleaner to skip the try catch for the demo. I always wonder why people don't just do this:

using(SqlConnection connection = new SqlConnection(...))
{
// code that uses the connection...
}

Of course true best practices dictate your code should only touch connections in a single location*. But I digress.

* I didn't say I follow this best practice all the time...but I digress even further. ;-)

2/2/2004 2:41:28 PM (Central Standard Time, UTC-06:00)  #    Trackback

How will Longhorn help?

Chris Sells talks about the sorry state of software design.

Hopefully Longhorn will fix this problem, but until then, I recommended that she return her computer to the manufacturer and get herself a Nintendo. After working through this with her for over an hour, I was only half kidding.

I'd love to see Chris, Robert, & anyone else on the Longhorn team answer the following question for each of the problems Chris described: How will Longhorn help make this easier for normal human beings?

2/2/2004 12:36:27 PM (Central Standard Time, UTC-06:00)  #    Trackback


Links

Categories

Archives