如何通过我的代码实现handle externl事件活动?... [英] How to implement handle externl event activity by my code?...

查看:78
本文介绍了如何通过我的代码实现handle externl事件活动?...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一名程序员,我编写了一些代码来练习wwf,并且我已经使用反射实现了**调用外部活动**。


$
1.首先,定义一个包含插件详细信息的xml文档:

< xml version =" 1.0 "编码= QUOT; UTF-8英寸>
$


2.其次,在某些代码中通过反射调用外部方法:



装配装配= Assembly.Load(assemblyName);
$
键入myInterface = assembly.GetType(interfaceName);
$
键入myClassType = null;

foreach(类型t在assembly.GetTypes())

{

if(myInterface.IsAssignableFrom(t)&& t.IsClass)

{

myClassType = t;

break;

}

}



MethodInfo methodInfo = myClassType.GetMethod(method);
$
object instance = Activator.CreateInstance(myClassType);
$
object result = methodInfo.Invoke(instance ,userData);
$


但是当我实现句柄外部事件模式时,我无法通过直接使用反射来完成它,然后我想连接委托,仍然是faild 。似乎mothod ** addService(service)**在wf端做了一些事情。我还能用反射实现它
吗?



Actualy,我不知道主机客户什么时候举办活动的细节,wf方面如何收到这个动作。这似乎是我的问题的关键...



谢谢你
ligong

As a programmer, I write some code to practice wwf, and I have implemented the **call external activity** by using reflection.

1. Firstly, define a xml document that contain a plugin detail:
<xml version="1.0" encoding="utf-8" >

2.Secondly, call the external method by reflection in some codes:

Assembly assembly = Assembly.Load(assemblyName);
Type myInterface = assembly.GetType(interfaceName);
Type myClassType = null;
foreach (Type t in assembly.GetTypes())
{
if (myInterface.IsAssignableFrom(t) && t.IsClass)
{
myClassType = t;
break;
}
}

MethodInfo methodInfo = myClassType.GetMethod(method);
object instance = Activator.CreateInstance(myClassType);
object result = methodInfo.Invoke(instance, userData);

But when I implement the handle external event pattern, i can't finish it by using reflection directly, then i want to hookup delegate, still faild. It seems that the mothod **addService(service)** do somethings inside the wf side. Could I still implement it by use reflection?

Actualy, I don't know the detail about when the host client raise an event, how wf side can recieve this action. it seemed that this is the key for my question...

Thanks
ligong

推荐答案

您好,

您可以通过两种方式在工作流中接收这些类型的事件:使用HandleExternalEvent或创建使用的自定义活动队列。当工作流到达HandleExternalEvent或创建队列的自定义活动时,
将变为空闲(一旦任何并行工作完成,或者如果没有其他活动并行则立即),然后主机可以恢复调度事件或将项目排入队列的工作流程。

There are 2 ways that you can receive these types of events in a workflow: by using the HandleExternalEvent or by creating a custom activity that uses Queues. When the workflow gets to a HandleExternalEvent, or a custom activity that creates a Queue, it will go idle (once any parallel work is complete, or immediately if there are no other activities in parallel) and then the host can resume the workflow by dispatching the event or enqueueing an item onto the queue.

以下是使用队列的示例:
http://www.microsoft.com/downloads/details.aspx?FamilyId=8C2EF231-0622-4BEC-9D35-9E86B64D94C5& ; displaylang = en

Here is an example of using Queues: http://www.microsoft.com/downloads/details.aspx?FamilyId=8C2EF231-0622-4BEC-9D35-9E86B64D94C5&displaylang=en

以下是使用CallExternalMethod / HandleExternalEvent的示例:

Here is an example using the CallExternalMethod/HandleExternalEvent:

http://msdn.microsoft.com/en-us/library/ms734592(VS.90)的.aspx

HTTP://msdn.m icrosoft.com/en-us/library/ms735947(VS.90).aspx

这有帮助吗?你可以使用内置的wf活动进行主机/工作流通信吗?或者你有不同的要求吗?

Does that help? Can you use the built-in wf activities for host/workflow communication or do you have a different requirement?

谢谢,

Steve Danielson [微软] ]

此帖子按"原样"提供。没有保证,也没有授予任何权利。

使用包含的脚本样本须遵守
http://www.microsoft.com/info/cpyright.htm

Steve Danielson [Microsoft]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

 


这篇关于如何通过我的代码实现handle externl事件活动?...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆