Tuesday, March 2, 2010

WF 4.0 Creating Custom AsyncCodeActivity

In WF 4.0 all the activities  are derived from Base activity called  Activity . In this blog post i am going to create custom AsyncCodeActivity.

AsyncCodeActivity and AsyncCodeActivity<T> are very similar to the CodeActivity. But AsyncCodeActivity execute Asynchronously and perform long running operations. suppose if you wanted to perform I/O or downloading any content from Web, you should create activity which drives from the AsyncCodeActivity or NativeActivity.

image

Here i am going to build Custom AsyncCodeActivity to retrieve HTML content for the given URL .

C# implementation of Custom AsyncCodeActivity  Source Lines. 

image

To Add Custom Activity Designer to this Activity please refer http://mstecharchitect.blogspot.com/2010/02/wf-40-custom-activity-designer.html. Now we need to test it.

Here I have a List of Web URLs which i need to download  the content (HTML) and save into a  file . To loop through the all URL collections and pass  into custom activity I am going use  ParallelForEach<T> Activity.

image

Now Build the WF as Shown Below and Test it.

image image

Nandri(Thanks)

SreenivasaRagavan.

3 comments:

機基差差 said...

快樂與人生,是最好的伴侶........................................

Preeti said...

Good post. Thanks for sharing.

Dương Nguyễn said...
This comment has been removed by the author.