首先定义IPersistenceDemo接口:
[ExternalDataExchange]
public interface IPersistenceDemo
{
event EventHandler<ExternalDataEventArgs> ContinueReceived;
event EventHandler<ExternalDataEventArgs> StopReceived;
}
实现本地服务PersistenceDemoService:
public class PersistenceDemoService : IPersistenceDemo
{
public event EventHandler<ExternalDataEventArgs> ContinueReceived;
public event EventHandler<ExternalDataEventArgs> StopReceived;
public void OnContinueReceived(ExternalDataEventArgs args)
{
if (ContinueReceived != null)
{
ContinueReceived(null, args);
}
}
public void OnStopReceived(ExternalDataEventArgs args)
{
if (StopReceived != null)
{
StopReceived(null, args);
}
}
}
whileActivity的条件为!this.IsComplete public sealed partial class PersistenceDemoWorkflow: SequentialWorkflowActivity
{
private Boolean isComplete = false;
public Boolean IsComplete
{
get { return isComplete; }
set { isComplete = value; }
}
public PersistenceDemoWorkflow()
{
InitializeComponent();
}
private void handleStopReceived_Invoked(object sender, ExternalDataEventArgs e)
{
//tell the WhileActivity to stop
isComplete = true;
}
}