工作流编程循序渐进(3:While活动)
2010-09-30 20:57:28 来源:WEB开发网5. 下面是完整的工作流类定义代码:
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace WhileActiviity
{
public sealed partial class Workflow1 : SequentialWorkflowActivity
{
//创建两个控制内外层循环的变量
private int i = 0;
private int j = 1;
public Workflow1()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
j = 1;
i++;
}
private void codeActivity2_ExecuteCode(object sender, EventArgs e)
{
if (i == j)
{
Console.Write("{0} * {1}={2} ", i, j, i * j);
Console.WriteLine("");
}
else
Console.Write("{0} * {1}={2} ", i, j, i * j);
j++;
}
private void codeActivity3_ExecuteCode(object sender, EventArgs e)
{
Console.Read();
}
}
}
自不必赘述了吧。
四、运行实例
按F5运行控制台程序,一般顺利的话,将得到如下图所示运行时快照。
图片看不清楚?请点击这里查看原图(大图)。
出处: http://zhuxianzhong.blog.51cto.com/157061/203304
更多精彩
赞助商链接