WF4 Parallel activity (CSWF4Parallel)

This code sample demonstrate the use of WF4 Parallel activity, ForEach activity and ParallelForEach activity.

C# (44.0 KB)
 
 
 
 
 
(0)
8,353 times
Add to favorites
5/5/2011
E-mail Twitter del.icio.us Digg Facebook
<Activity mc:Ignorable="sap" x:Class="CSWF4Parallel.Workflow1" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Parallel sad:XamlDebuggerXmlReader.FileName="Workflow1.xaml" sap:VirtualizedContainerService.HintSize="772,523" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">
        <Parallel.Variables>
            <Variable x:TypeArguments="s:Int32[]" Default="[{1, 2, 3}]" Name="numberArray" />
        </Parallel.Variables>
        <Sequence DisplayName="Sequence1" sap:VirtualizedContainerService.HintSize="309,477">
            <sap:WorkflowViewStateService.ViewState>
                <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                    <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                </scg3:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <ForEach x:TypeArguments="x:Int32" sap:VirtualizedContainerService.HintSize="287,353" Values="[numberArray]">
                <ActivityAction x:TypeArguments="x:Int32">
                    <ActivityAction.Argument>
                        <DelegateInArgument x:TypeArguments="x:Int32" Name="item" />
                    </ActivityAction.Argument>
                    <Sequence sap:VirtualizedContainerService.HintSize="257,247">
                        <sap:WorkflowViewStateService.ViewState>
                            <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                                <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                            </scg3:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                        <WriteLine sap:VirtualizedContainerService.HintSize="211,61" Text="[&quot;Sequence1:&quot; + item.ToString]" />
                        <Delay Duration="00:00:05" sap:VirtualizedContainerService.HintSize="211,22" />
                    </Sequence>
                </ActivityAction>
            </ForEach>
        </Sequence>
        <Sequence DisplayName="Sequence2" sap:VirtualizedContainerService.HintSize="309,477">
            <sap:WorkflowViewStateService.ViewState>
                <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                    <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                </scg3:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <ParallelForEach x:TypeArguments="x:Int32" sap:VirtualizedContainerService.HintSize="287,353" Values="[numberArray]">
                <ActivityAction x:TypeArguments="x:Int32">
                    <ActivityAction.Argument>
                        <DelegateInArgument x:TypeArguments="x:Int32" Name="item" />
                    </ActivityAction.Argument>
                    <Sequence sap:VirtualizedContainerService.HintSize="257,247">
                        <sap:WorkflowViewStateService.ViewState>
                            <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                                <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                            </scg3:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                        <WriteLine sap:VirtualizedContainerService.HintSize="211,61" Text="[&quot;Sequence2:&quot; + item.ToString]" />
                        <Delay Duration="00:00:05" sap:VirtualizedContainerService.HintSize="211,22" />
                    </Sequence>
                </ActivityAction>
            </ParallelForEach>
        </Sequence>
    </Parallel>
</Activity>