I'm using Visual Studio 2010 Beta 2 to get a head start on learning to use WF4. I'm working in the designer to create a xaml file. I've added a ForEach activity, and inside that ForEach activity have a flowchart that does some conditional processing. I want to be able to break out of the ForEach if one of the conditions is true, but can't figure out how to do so. In a C# code behind file that would just be to issue a break; , but in the xaml workflow designer, I don't see any mechanism for breaking from a loop. Any suggestions?
Android – Windows Workflow Foundation 4.0 Break Out of ForEach Activity
android-activityforeachwindowsworkflow-foundation-4xaml
Related Solutions
New answer, powershell
TCP
Get-Process -Id (Get-NetTCPConnection -LocalPort YourPortNumberHere).OwningProcess
UDP
Get-Process -Id (Get-NetUDPEndpoint -LocalPort YourPortNumberHere).OwningProcess
Old answer, cmd
C:\> netstat -a -b
(Add -n to stop it trying to resolve hostnames, which will make it a lot faster.)
Note Dane's recommendation for TCPView. It looks very useful!
-a Displays all connections and listening ports.
-b Displays the executable involved in creating each connection or listening port. In some cases well-known executables host multiple independent components, and in these cases the sequence of components involved in creating the connection or listening port is displayed. In this case the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions.
-n Displays addresses and port numbers in numerical form.
-o Displays the owning process ID associated with each connection.
A FlowSwitch works with string values at the moment. Try converting the InArgument to a string.
Example XAML:
<p:Activity mc:Ignorable="" x:Class="WorkflowConsoleApplication2.Flowchart1" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities/design" xmlns:__Flowchart1="clr-namespace:WorkflowConsoleApplication2;" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<p:Flowchart StartNode="{x:Reference __ReferenceID0}" sad:XamlDebuggerXmlReader.FileName="c:\temp\WorkflowConsoleApplication2\WorkflowConsoleApplication2\Flowchart1.xaml">
<WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, s:Object">
<av:Point x:Key="ShapeLocation">275,10</av:Point>
<av:Size x:Key="ShapeSize">50,50</av:Size>
<av:PointCollection x:Key="ConnectorLocation">300,60 300,110</av:PointCollection>
</scg:Dictionary>
</WorkflowViewStateService.ViewState>
<p:FlowSwitch x:Name="__ReferenceID0" Expression="["2"]">
<p:FlowSwitch.Default>
<p:FlowStep x:Name="__ReferenceID1">
<WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, s:Object">
<av:Point x:Key="ShapeLocation">235,293</av:Point>
<av:Size x:Key="ShapeSize">200,34</av:Size>
</scg:Dictionary>
</WorkflowViewStateService.ViewState>
<p:WriteLine>["Default"]</p:WriteLine>
</p:FlowStep>
</p:FlowSwitch.Default>
<WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, s:Object">
<av:Point x:Key="ShapeLocation">270,110</av:Point>
<av:Size x:Key="ShapeSize">60,60</av:Size>
<av:PointCollection x:Key="Default">300,170 285,170 285,283 335,283 335,293</av:PointCollection>
<av:PointCollection x:Key="1Connector">300,170 300,205 330,205</av:PointCollection>
<av:PointCollection x:Key="2Connector">300,170 300,180 290,180 290,270 340,270</av:PointCollection>
</scg:Dictionary>
</WorkflowViewStateService.ViewState>
<p:FlowStep x:Name="__ReferenceID2">
<x:Key>
<x:String>1</x:String>
</x:Key>
<WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, s:Object">
<av:Point x:Key="ShapeLocation">330,188</av:Point>
<av:Size x:Key="ShapeSize">200,34</av:Size>
</scg:Dictionary>
</WorkflowViewStateService.ViewState>
<p:WriteLine>["Its 1 "]</p:WriteLine>
</p:FlowStep>
<p:FlowStep x:Name="__ReferenceID3">
<x:Key>
<x:String>2</x:String>
</x:Key>
<WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, s:Object">
<av:Point x:Key="ShapeLocation">340,253</av:Point>
<av:Size x:Key="ShapeSize">200,34</av:Size>
</scg:Dictionary>
</WorkflowViewStateService.ViewState>
<p:WriteLine>["Its 2"]</p:WriteLine>
</p:FlowStep>
</p:FlowSwitch>
<x:Reference>__ReferenceID2</x:Reference>
<x:Reference>__ReferenceID3</x:Reference>
<x:Reference>__ReferenceID1</x:Reference>
</p:Flowchart>
</p:Activity>
Related Topic
- Sql – Windows Workflow Foundation 4.0 and Persistence
- R – Windows Workflow Foundation 4.0 and Persistence
- R – Windows Workflow Foundation 4.0 Pick Activity Containing a Delay Activity
- R – Windows Workflow Foundation 4.0 and Tracking
- R – Windows Workflow Foundation 4.0 and Tracking
- Php – break out of if and foreach
Best Answer
There is no break equivalent in WF4. So either you need to start adding conditional logic to skip the next loops or throw an exception and catch that outside of the ForEach and continue.
And I agree that neither is a very nice option :-(