Lambda expression simplify code

One of the nice new features in Visual Basic 9 are lambda expressions. They where actually added as one of the underlying pieces for LINQ. But besides enabling LINQ you can use them in all sorts of places. One of the places they really help me is in places where I previously needed to declare a delegate and use that. Take for example the following code where I use the ThreadPool to do some work:Private Sub btnStart_Click() Handles btnStart.Click ThreadPool.QueueUserWorkItem(AddressOf DoWork) End Sub Private Sub DoWork(ByVal state As Object) For index As Integer = 1 To 100 SetProgressLabel(index) Thread.Sleep(100) Next … Continue reading Lambda expression simplify code

DevDays and The Hague Jazz

Last week was pretty interesting and busy [:)] First we had the DevDays on Thursday and Friday. I was there to answer questions from the audience. I didn’t get too many questions so I could take my time and actually spend around 90 minutes answering questions from one and around 1 hour with another. Add some more smaller questions and it kept me busy but still left time to check a few sessions. One notable session I watched was by Neno Loje. It was the first time I saw him speak and he did a session about advanced ClickOnce. He … Continue reading DevDays and The Hague Jazz

Validating workflow activities at runtime

As I mentioned in my previous blog post adding a custom ActivityValidator class to an activity validates it at runtime as well as at design time. So when is this runtime validation done and what happens when it fails? The when part is when the WorkflowInstance object is first created using one of the overloads of the WorkflowRuntime CreateWorkflow function. This means that the activity cannot really validate all properties as they are when it starts executing. After all when it depends on some data provided by another activity it needs to wait until this other activity has executed. And … Continue reading Validating workflow activities at runtime

Runtime modification of workflow’s

Modifying already executing workflow’s is a very powerful option. Now, as with most advanced options, not something you are going to need every day but certainly something to be aware of and use when the needed.   First lets take a quick look at why we would want to modify an already running workflow in the first place. Consider the following scenario. You have long running, lets assume a year on average, and part of the workflow has to do with shipping products. And lets assume that the shipping is done by any one of a number op shippers and … Continue reading Runtime modification of workflow’s

Validating workflow activity metadata

There are several options for validating properties on a custom activity. Besides the possibility of using an ActivityValidator as described here we can also use the ValidationOptionAttribute. Now the ValidationOptionAttribute isn’t useful all the time and only for a limited set of properties. First of all the limited set of properties. This will only work for dependency properties defined with DependencyPropertyOptions.Metadata. This makes them metadata and they cannot be changed at runtime, only design time. The second is the limitation in that is can only enforce a required field. No specific values or even an error tekst. So using this … Continue reading Validating workflow activity metadata

SQL Server Compact and 64 bits

The current version of SQL Server Compact has no support for 64 bits computing. While this may seem a problem if you want to deploy you application on a 64 bits version of Windows it really isn’t most of the time. In fact if you change your assembly from the default AnyCPU to x86 compatible it will work just fine using Windows On Windows (WOW).   But even better there will soon be a native 64bits version of SQL Compact. This isn’t in the beta version that is distibrited with Visual Studio 2008 SP1 beta but Steve Lasker promises it … Continue reading SQL Server Compact and 64 bits

Validating custom activities in the Workflow designer

Create a derived class from ActivityValidator and add it to your custom activity using the ActivityValidatorAttribute. For example: [ActivityValidator(typeof(ValidatedActivityValidator))] public partial class ValidatedActivity : SequenceActivity {} The validator class now look like this:class ValidatedActivityValidator : ActivityValidator { public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { ValidationErrorCollection result = base.Validate(manager, obj); ValidatedActivity activity = obj as ValidatedActivity; if (activity != null && activity.Parent != null) { if (activity.AValueBetween1And250 < 1) result.Add( new ValidationError(“The value is to small”, 102, false, “AValueBetween1And250″)); if (activity.AValueBetween1And250 > 250) result.Add( new ValidationError(“The value is to big”, 103, true, “AValueBetween1And250″)); } return result; } } Note that … Continue reading Validating custom activities in the Workflow designer

How to Download all of Visual Studio 2008 SP1

 VS2008 SP1 Beta is quite a package. By default the installation downloads the packages as needed and when needed. Now that is just fine if you only need to install a single machine. But when you need to install multiple, possibly virtual, machines like I have to it just wastes a lot of bandwidth and time [:(]. Fortunately there is a solution and it can be found here in the blog post by Heath Stewart.Enjoy! 

Microsoft Netherlands Community DevCast

The Dutch Microsoft office has posted the first of the Community DevCast we recorded. The host is Alex Thissen who actually does most of the work as he also edits the screencasts so don’t forget to thank him next week when you run into him at the Dutch DevDays. I am happy to say that amongst the first 6 screencasts released are no less that 4 I did with Alex about Workflow Foundation. And there are more to come so stay tuned. The other two are about C# and done by Dennis Vroegop again with Alex as the host. You … Continue reading Microsoft Netherlands Community DevCast

Changing the default icon of a custom workflow activity

By default every custom workflow activity shows the same icon. And using an icon that help understand what the activity actually does makes life so much easier for the user of your activity. And remember he is a developer so some day he might just return the favor [:)]   The default looks like this.   So changing the icon isn’t hard there are just a few steps that might catch you if you aren’t careful. This is what my demo project looks like:   Add the new image to the project. In my case I added a folder named … Continue reading Changing the default icon of a custom workflow activity