0

从一些文章中读到,并行活动不会在不同的线程中执行子活动,除非子活动本身是异步的。所以我刚刚构建了一个名为 AsyncTask 的自定义 AsyncCodeActivity,它有一个 Activity(名为 SyncActivity)作为 InArgument,在 BeginExecute 中我调用 Task.Factory.StartNew(() => WorkflowInvoker(SyncActivity))。但我也想要一个看起来与并行活动完全相似并且具有与并行活动相同的功能(比如拖动一些活动并将其放在其中一个分支中)的设计器。但是当一些活动被拖放到其中一个分支中时,它应该使用 AsyncTask AsyncActivity 在内部异步运行。我怎么做?

4

1 回答 1

1

I understand your problem. Building an activity designer (control in WF) is not that hard. Just use the WorkflowItemPresenter like shown on MSDN.

To fulfill your further requirements we have to keep in mind that activities take parameters. You have to pass them to your SyncActivity through the outer AsyncActivity. Therefore you have to enhance your activity designer by dynamically created input controls. To create those you need to access the public properties of your SyncActivity (e. g. by Reflection). I found it hard to even access the inner activity, because you have to work yourself through a so called "ModelItem". An easier approach might be passing the parameters by creating a chain of variables.

And by the way: The task factory helps you creating tasks, but it doesn't force the creation of new threads. Just keep the task/thread model in mind ;-)

Regards Jan

于 2013-09-04T19:49:47.673 回答