Andrew Zhu RSS 2.0
# Monday, June 21, 2010


Download the code here:

CSWF4Designer.zip (77.99 KB)
Monday, June 21, 2010 10:09:49 AM (China Standard Time, UTC+08:00)  #    Comments [2] - Trackback
Designer
# Thursday, June 10, 2010
To inspect the Workflow tree, we can use WorkflowInspectServices:
        /// <summary>
        /// Use this method to list all sub activities
        /// WorkflowInspectServices: Provides methods 
/// for working with the runtime metadata for an activity tree.
/// </summary> /// <param name="rootWF"></param> /// <param name="indent"></param> private static void InspectWorkflow(Activity rootWF, int indent) { IEnumerator<Activity> activities =
WorkflowInspectionServices.GetActivities(rootWF).GetEnumerator(); Console.WriteLine(new string(' ', indent) + rootWF.DisplayName + " id:" + rootWF.Id); while (activities.MoveNext()) { InspectWorkflow(activities.Current, indent + 2); } }
To Inspect workflow Variables and Arguments, we can use ActivityBuilder:
        /// <summary>
        /// Use this method to list all Variables, InArguments and OutArguments
        /// </summary>
        private static void LoadWFFromXaml(){
            string xamlWorkflow =
                File.ReadAllText(@"Path\Workflow1.xaml");
            StringReader sr = new StringReader(xamlWorkflow);
            XamlXmlReader xxr = new XamlXmlReader(sr);
            XamlReader xr = ActivityXamlServices.CreateBuilderReader(xxr);
            ActivityBuilder ab = XamlServices.Load(xr) as ActivityBuilder;

            foreach (var p in ab.Properties) {
                Console.WriteLine("Name:" + p.Name);
                Console.WriteLine("Type:" + p.Type);
                Console.WriteLine("Attribute:" + p.Attributes);
                Console.WriteLine("Value:" + p.Value);             
                Console.WriteLine("---------------------------------");
            }
        }

Thursday, June 10, 2010 6:22:30 PM (China Standard Time, UTC+08:00)  #    Comments [0] - Trackback
WF4
# Wednesday, May 26, 2010
To use InvokeWorkflowActivity, see Using the InvokeWorkflowActivity Activity The only thing we need to do is assign a workflow type to the TargetWorkflow property of InvokeWorkflow activity.

Once we set the TargetWorkflow property, the Properties panel will be updated and the sub-workflow's dependence properties will show up in the Properties panel of InvokeWorkflowActivity.

We can set static values for these properties or bind each property to a property in the current workflow. Since the sub-workflow instance will executes on its own thread, you cannot retrieve sub-workflow output from its parents workflow.

InvokeWorkflowActivity also provide a invoking event handler for set sub workflow parameters in code. But I can not find any documents or blog articles talk about how to set parameters in the invoking event handler, So after some research and test, I wrote this code and it works:

        private void invokeWorkflowActivity1_Invoking(object sender, EventArgs e) {

            var parameterBindings = this.invokeWorkflowActivity1.ParameterBindings;

            parameterBindings[0].Value = "value of parameter";

        }


Hope this will be helpful to you.

PS: Question from MSDN forum:
InvokeworkFlow Activity in Windows WorkFlow Foundation

Wednesday, May 26, 2010 9:58:07 AM (China Standard Time, UTC+08:00)  #    Comments [1] - Trackback
Windows Workflow Foundation-WF
# Tuesday, May 04, 2010
You can start from here:
Introduction to Workflow 4.0
http://channel9.msdn.com/learn/courses/VS2010/WCFWF/IntroToWF/

To learn more about WF4, read the WF4 document:
http://msdn.microsoft.com/en-us/library/dd489441(v=VS.100).aspx

To learn how to apply WF4 in real applications, check samples:
http://msdn.microsoft.com/en-us/library/dd483375(v=VS.100).aspx

To get deep into WF4, follow this blog(go with flow):
http://blogs.msdn.com/flow/default.aspx
and this one (matt's blog)
http://blogs.msdn.com/mwinkle/default.aspx
And .NET endpoint:
http://blogs.msdn.com/endpoint/default.aspx:

If you can read Chinese, I recommend you read through this blog:
http://www.cnblogs.com/foundation/
If you get any problems, Ask your question in WF4 forum:
http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/threads

Tuesday, May 04, 2010 3:59:31 PM (China Standard Time, UTC+08:00)  #    Comments [0] - Trackback
WF4
# Saturday, April 17, 2010

ETW stands for Event Tracking for Windows .So, what is ETW, simply put, ETW tracking means you can see tracking information in the famous Event Viewer.

How to do it

Let us create an extremely simple workflow just for tracking.
Workflow: Workflow1.xaml


Enable ETW tracking:

Open Event Viewer, Navigate to Event Viewer->Applications and Services Logs->Microsoft->Windows->Application Server-Applications. Right-click Application Server-Applications and select View->Show Analytic and Debug Logs. After refreshing the node, you should see:


Host: Program.cs


Result:

After running the workflow, you right-click the Analytic node, and select refresh, then you should see:


How it works

Here is the WF4 Tracking architecture:

Saturday, April 17, 2010 10:47:50 AM (China Standard Time, UTC+08:00)  #    Comments [2] - Trackback
WF4
# Sunday, April 04, 2010

WebRequest class enable us make an http request in code. Usually, every WebRequest-Call requires some time span, several seconds or even minutes. If there is only one request, you can wait the response, but what you going to do if you have to make many more requests, may be 100. every request use several seconds, 100 request will hang your program.

Then, you come up a good idea: why not use multi threads. one request, one thread. But do you know how expensive is to initialize a thread? If you are writing .Net Manage code, each thread will reserve 1MB memory. 100 threads will use up 100MB memory. No way, multi thread is not an option. So what we should do. In this piece of blog I will introduce an a-synchronization way to make 10 http requests asynchronously without blocking the main thread:

Sunday, April 04, 2010 11:30:14 AM (China Standard Time, UTC+08:00)  #    Comments [0] - Trackback
DotNet
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Statistics
Total Posts: 147
This Year: 0
This Month: 0
This Week: 0
Comments: 174
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
朱书栋|Andrew Zhu
Sign In
All Content © 2012, 朱书栋|Andrew Zhu
DasBlog theme 'Business' created by Christoph De Baene (delarou)