net comments edit

In this Two Minute WF, I’m going to tell you about WorkflowInstance.

This is a really simple one: A WorkflowInstance is - wait for it - a single instance of a workflow. Yes, it really is that simple. You pick your workflow type, fill in the activities it’ll use, and you have a workflow definition. Once you have the definition, you instantiate it and start it running. It’s sort of like defining your class/type and then newing one up. For objects it’s like this:

MyCustomType myVar = new MyCustomType();

For workflows, it’s like this:

using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
  AutoResetEvent wh = new AutoResetEvent(false);
  workflowRuntime.WorkflowCompleted +=
    delegate(object sender, WorkflowCompletedEventArgs e) {wh.Set();};
  workflowRuntime.WorkflowTerminated +=
    delegate(object sender, WorkflowTerminatedEventArgs e) {wh.Set();};
  WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(MyCustomWorkflowType));
  instance.Start();
  wh.WaitOne();
}

In the example, I not only create an instance of my custom workflow type, but I also start it running. It’s a little more complex than just creating a new object, but it’s not that much worse.

The WorkflowRuntime is responsible for instantiating workflows and starting them running. Since workflow instances run on a different thread than the main program, I’m using an AutoResetEvent to do thread synchronization - we don’t want to end the program or dispose of the WorkflowRuntime until the WorkflowInstance has had a chance to complete its run.

Something to watch for when you’re working in a larger environment with lots of instances - you only get one WorkflowRuntime for a given AppDomain. What that means is the WorkflowCompleted and WorkflowTerminated events are for all WorkflowInstances - you don’t get one for each instance. Be careful when subscribing to these events when you just want info on a single instance. If you forget to unsubscribe from the event and the event subscriber goes out of scope, you may have a memory leak on your hands. (The Garbage Collector won’t clean up the now-unreferenced event subscriber because there’s still one reference to it - the subscription to the global WorkflowRuntime event.)

Jonathan Coulton plays the Mission St. Theater - Click for
PhotosJenn and I saw Jonathan Coulton with Paul and Storm last night at the Mission St. Theater in a sold out show.

It was awesome.

We got there about an hour before the doors opened and it’s good we did because the line was already pretty long. By the time the doors opened, it was around the corner and well down the block.

As we were waiting in line, Jonathan, Paul, and Storm all walked past to get to the front door… and then walked right by again to head to the artist entrance.

We got great seats right up front with no one blocking our view. Paul and Storm opened and we were very pleasantly surprised - I’d never heard them before, but they’ve made new fans of us. They played for about an hour and then there was a break before Jonathan Coulton came on.

When he did come on, it was great. He really played the crowd well and the small venue added to it. He sang all of the great ones - Re: Your Brains, Still Alive, Code Monkey, Skullcrusher Mountain - and a bunch of others, also great. During Re: Your Brains, the audience sang the zombie part. Gotta love it.

It was sort of a crazy crowd. Great people, everyone really wanted to be there, but… well, only at a Coulton show could I look down the line and see people reading the Learning Perl book. A wonderfully geeky mix of folks.

I posted some pictures on Flickr of the show. They’re not the most exciting pix because the show wasn’t really flashy, but they’re decent and show you how close we were.

I ended up getting the entire Thing a Week box set and the Smoking Monkey album. Support your favorite artists, right? Another cool surprise - the Thing a Week box set was signed and numbered inside. Awesome.

We’ll definitely be going again when he comes back to town.

GeekSpeak comments edit

Based on my previous all-in-one experience with the HP C7280, when I brought the Canon PIXMA MX850 home, the first thing I did after I installed it was to try out a scan. I didn’t print, I didn’t copy, I just scanned.

Freaking garbage.

Not as bad as the HP C7280, mind you, but still pretty bad. I tried a book cover and two different CD covers. All of them came out with horrible Moire patterns and pixel artifacts.

I never printed a single page (other than the printer head calibration). It’s already in the box to be taken back.

I’ve learned something, but I’m not sure what.

  • Should I not trust all-in-one units because their scan capabilities will be mediocre at best compared to a dedicated scanner?
  • Should I not trust units with CIS scanners (as both the HP and Canon had) and look for something with a CCD scanner?
  • Should I not trust units that can attach over the network and/or USB? (Though the connection didn’t matter when I tried it out both ways, so I doubt it’s this one.)

Anyway, back to square one.