开发者

WF4 : Custom activity with child activity

How can I create a custom activity for Workflow Foundation 4 that host a child activity (or several)?

The idea is to create something similar to the TryCatch activity where you can specify an activity that goes in the try part and another in the finally part.开发者_运维百科 However I need my own custom business logic.


Derive from NativeActivity. Use public properties to hold your children. Like

public Activity Body { get; set; }

override NativeActivityExecute(). Call NativeActivityContext.ScheduleActivity(this.Body). Use the overload that takes completion handlers - if you want some kind of sequential execution, that is, because scheduled activities are executed only after Execute() returns.

This is the basics.


The article "Authoring Custom Control Flow Activities in WF 4" available at http://msdn.microsoft.com/en-us/magazine/gg535667.aspx explains how to create your own custom control flow activities (like for example a Sequence) using WF4.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜