Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Posted in Uncategorized | 1 Comment

Programmatically adding a child activity from the activity designer

A child activity can be added to a composite activity using the composite activity’s designer object using the following method
 
CompositeActivityDesigner.InsertActivities
 
This is useful when you have to add a specific child or a bunch of children based on an designer verb, (  e.g. using context menu).

Posted in Uncategorized | 2 Comments

How to determine if a given composite activity is a custom activity

When walking the workflow’s activity tree, you’ll encounter all the child activities of composite activities including, the children that were dropped into activity.xoml or activity.cs of  the composite activity. If you ever need to find just  the activities dropped into the current workflow, and not the ones indireclty in the tree throgu the custom activities, here is what you can do.
 
Ignore an activity if somewhere in its path to the root exists a composite such that, an instance of that composite activity type when created using activator create instance ,has child activities in it already.
Posted in Windows Workflow Foundation | 11 Comments

Yod’m 3D

A very nice virtual desktop manager for Windows.
Posted in Computers and Internet | Leave a comment

Rehosted Workflow designer and State machine designer layout

If you wondered why all your states were stacked on each other when rehosting the workflow designer, here is what you need to do.

The workflow designer saves the layout information in a .layout file corresponding to the workflow file. ( StateMachineWorkflow1.xoml or StateMachineWorkflow1.cs will have a StateMachineWorkflow1.layout generated by the VS workflow designer).

When rehosting the state machine workflow, in your rehosting app, use a derived WorfklowDesignerLoader instead of the base and inside PerformLoad() call LoadDesignerLayout() and point the xml reader to your layout file.

LoadDesignerLayout(XmlReader layoutReader, out IList layoutLoadErrors)

alternatively if you are loading the workflow from a compiled assembly you could use this method

LoadDesignerLayoutFromResource(Type type, string manifestResourceName, out IList errors)

Posted in Uncategorized | 8 Comments

Winforms and non-STA Threads

Recently I came across a request for a workaround the STAThread problem from a customer. He wanted to show a Save file dialog from within a CallExternalMethod activity. Since this thread is owned by the workflow instance there is no way to set the apartment state of this thread to ApartmentState.STA. This snippet works around the problem. ( Although In general using block UI elements like this inside of workflows is not recommended)

string fileSavePath;
Thread newThread = new Thread(delegate()
{
          using (SaveFileDialog saveFileDialog = new SaveFileDialog())
          {
                 if (saveFileDialog.ShowDialog() == DialogResult.OK)
                 {
                           fileSavePath = saveFileDialog.FileName;
                 }
           }
});
newThread.SetApartmentState(ApartmentState.STA);
newThread.Start();
newThread.Join();

Posted in Windows Workflow Foundation | 35 Comments

Zune Zune

I won a Zune a few days back in raffle that was a part of the Microsoft’s CSD Giving Campaign. The Zune will be released on Nov 14th 2006. Eagerly waiting for my Zune :)
 
Posted in Uncategorized | 9 Comments