declare a event In My SequentialWorkflow! how can it doing?
In workflow codes
namespace WorkflowLibrary1
{
public sealed partial class Workflow1: SequentialWorkflowActivity
{
public event EventHandler RaiseedEvent;
public Workflow1()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
RaiseedEvent(sender, e);
}
}
}
In form codes
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Workflow.Runtime;
using WorkflowLibrary1;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
protected WorkflowRuntime wr;
public Form1()
{
InitializeComponent();
wr = new WorkflowRuntime();
wr.StartRuntime();
}
private void button1_Click(object sender, EventArgs e)
{
WorkflowInstance workflowInstance = wr.CreateWorkflow(typeof(WorkflowLibrary1.Workflow1));
workflowInstance.Start();
}
}
}
My question is how to get raise event "RaiseedEvent"?
Hi,
I am not quite sure I understand your code, but if you need to have the Workflow pause and wait for an event before it continues, then this is fairly simple to do. THere is a good example of this in the Hands on Labs. The latest Hands on Labs for RC0 are available for download here:
http://www.microsoft.com/downloads/details.aspx?FamilyId=2E575633-E357-4EE7-AAFF-34138F00E830&displaylang=en
I have created a bare bones sample on my blog that illustrates how to do this. You can download the sample from here:
http://blogs.msdn.com/sdanie/archive/2006/07/07/659106.aspx
Basically you define an interface that has the ExternalDataExchangeAttribute, which contains the events you want to handle in the workflow, and optionally any methods you want to call from the workflow. You implement this interface, and you register an instance of this into an instance of ExternalDataExchangeService that is registered with the Workflow runtime:
ExternalDataExchangeService dataService = new ExternalDataExchangeService();
workflowRuntime.AddService(dataService);
MyService service = new MyService();
dataService.AddService(service);
Then in your Workflow you can use CallExternalMethod activity to call the methods in your local service and HandleExternalEvent to handle any events that are defined by the local service.
My sample is very simple, but there is much more detail and complex samples in the hands on labs.
Steve Danielson [Microsoft]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm