开发学院软件开发C语言 学WF系列(六)——工作流模拟投票项目 阅读

学WF系列(六)——工作流模拟投票项目

 2010-10-01 08:26:22 来源:WEB开发网   
核心提示: Form1.cs:publicpartialclassForm1:Form{privateWorkflowRuntimeworkflowRuntime;privateWorkflowInstanceinstance;privateAutoResetEventwaitHandle;privates

Form1.cs:

public partial class Form1 : Form
{
  private WorkflowRuntime workflowRuntime;
  private WorkflowInstance instance;
  private AutoResetEvent waitHandle;
  private string result = String.Empty;
  int count;
  public Form1()
  {
    InitializeComponent();
    workflowRuntime = new WorkflowRuntime();
    workflowRuntime.StartRuntime();
    waitHandle = new AutoResetEvent(false);
    workflowRuntime.WorkflowCompleted += delegate(object sender1, WorkflowCompletedEventArgs e1)
    {
      result = e1.OutputParameters["Result"].ToString();
      count = Convert.ToInt32(e1.OutputParameters["CountAll"]);
      waitHandle.Set();
    };
  }

  private void button1_Click(object sender, EventArgs e)
  {
    Dictionary<string, object> dic = new Dictionary<string, object>();
    ArrayList list = new ArrayList();
    for (int i = 0; i < this.checkedListBox1.CheckedItems.Count;i++ )
    {
      list.Add(this.checkedListBox1.CheckedItems[i].ToString());
    }
    dic.Add("ArrayL", list);
    instance = workflowRuntime.CreateWorkflow(typeof(Workflow1), dic);
    instance.Start();

    waitHandle.WaitOne();

    MessageBox.Show(result);
    MessageBox.Show(count.ToString());    
  }
}

上一页  1 2 3 4 5  下一页

Tags:WF 系列 工作流

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接