InvokeWorkflowActivity是干吗用的,CallExternalMethodActivityHandleExternalEventActivity还好,知道等等外面干活的,InvokeWorkflowActivity可到好,傻小子放炮,点上就跑,也不知站住看一下,看看MS对它的解释:

Asynchronously runs one workflow from another. This class cannot be inherited.
InvokeWorkflowActivity then creates and invokes a workflow instance of the specified type, passing the parameters that have been provided. As soon as the workflow has been invoked, the InvokeWorkflowActivity finishes immediately.
Use the InvokeWorkflowActivity to start one workflow from another. The InvokeWorkflowActivity completes before the launched workflow starts executing and the next activity in the workflow branch is executed.

异步,而且还没回调,异步我要你干吗。

看一下这个例子吧,用了一个多线程常用的方式解决了调用子流程的问题,看这个例子注意以下几点:

1.不用InvokeWorkflowActivity也能实现调用子流程
2.这个例子的中心思想不是如何用InvokeWorkflowActivity调用子流程,我有N多比这简单的方法,这个例子的主要演示了如何将工作流的业务处理封装到自定义引擎中

调用子流程思路如下


本例是通过重写WorkflowRuntime实现,也就是说以上活动没在在宿主中实现,全过程对宿主来说是一个黑盒

publicclass控制类
{

//外部事件
[Serializable()]
publicclass事件标志:System.Workflow.Activities.ExternalDataEventArgs
{
privateGuid实例GUID_存值;

publicstring自定义存值;

public事件标志(GuidinstanceId)
:
base(instanceId)
{
this.实例GUID_存值=instanceId;
}


publicGuid实例GUID
{
get{returnthis.实例GUID_存值;}
set{this.实例GUID_存值=value;}
}

}


[System.Workflow.Activities.ExternalDataExchange()]
publicinterface外部事件映射接口
{
eventSystem.EventHandler<事件标志>子流程完成事件;
}


publicclass功能类_外部事件:外部事件映射接口
{
publiceventEventHandler<事件标志>子流程完成事件;
publicvoid触发子流程完成事件(objectsender,Guidid,string自定义存值)
{
事件标志e
=new事件标志(id);
e.自定义存值
=自定义存值;
子流程完成事件(sender,e);
}

}


//外部方法
[System.Workflow.Activities.ExternalDataExchange()]
publicinterface外部方法映射接口
{void子流程完成(string所属父流程ID,string流程ID);}

publicclass功能类_外部方法:外部方法映射接口
{
publicstring父流程ID=null;
publicstring当前流程ID=null;
publicvoid子流程完成(string所属父流程ID,string流程ID)
{
当前流程ID
=流程ID;
父流程ID
=所属父流程ID;
Console.WriteLine(
"方法已被触发");
}


}


//改写引擎
publicclass自定义工作流引擎:System.Workflow.Runtime.WorkflowRuntime
{
System.Workflow.Activities.ExternalDataExchangeService外部数据通信服务;
功能类_外部事件外事
=new功能类_外部事件();
功能类_外部方法外方
=new功能类_外部方法();

public自定义工作流引擎()
:
base()
{
外部数据通信服务
=newSystem.Workflow.Activities.ExternalDataExchangeService();
test.宿主(
"自定义引擎中","准备向引擎添加外部数据通信服务");
this.AddService(外部数据通信服务);
外部数据通信服务.AddService(外事);
外部数据通信服务.AddService(外方);
this.WorkflowCompleted+=newEventHandler<System.Workflow.Runtime.WorkflowCompletedEventArgs>(自定义工作流引擎_WorkflowCompleted);
}


void自定义工作流引擎_WorkflowCompleted(objectsender,System.Workflow.Runtime.WorkflowCompletedEventArgse)
{

if(外方.父流程ID!=null)
{
Console.WriteLine(
"内部完成事件:触发:子流程完成事件");
外事.触发子流程完成事件(
"wxd",newGuid(外方.父流程ID),"wxwinter");
外方.父流程ID
=null;
}

Console.WriteLine(
"内部完成事件:工作流完成");
}




}


}

例子 WWF调试模板(子流程).rar


优质内容筛选与推荐>>
1、ASP利用XMLHTTP抓取网页内容
2、GDAL源码剖析(四)之命令行程序说明二
3、jqgrid单元格合并
4、VS2017专业版和企业版激活密钥
5、mysql自动化备份方案


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号