My first workflow \ "Hello Word \"
Create a state machine workflow project \ "WorkflowLibrary1 \"
Private void codeactivityappsexecutecode (object sender, EventArgs e)
{
// System. Windows. Forms. MessageBox. Show (\ "sdlkalksadfasdF \");
CodeActivity cd = new CodeActivity ();
Console. writeLine (\ "Hello, from \ '{0 }\'. \ nI \'m an instance of the {1} class. \ ", cd. name, cd. toString ());
}
2. Add the new project (console program) \ "leleapplication1 \" Code as follows:
Class Program
{
Static AutoResetEvent waitHandle = new AutoResetEvent (false );
Static void Main (string [] args)
{
// Form1 fr = new Form1 ();
// Fr. Show ();
WorkflowRuntime wn = new WorkflowRuntime ();
Wn. StartRuntime ();
Wn. WorkflowCompleted + = new EventHandler <WorkflowCompletedEventArgs> (OnWorkflowCompleted );
Type type = typeof (WorkflowLibrary1.Workflow1 );
WorkflowInstance inst = wn. CreateWorkflow (type );
Inst. Start ();
// Wn. CreateWorkflow (type );
WaitHandle. WaitOne ();
Wn. StopRuntime ();
Console. WriteLine (\"\");
Console. WriteLine (\"\");
Console. WriteLine (\ "=========================== \");
Console. WriteLine (\ "Press any key to exit .\");
Console. WriteLine (\ "=========================== \");
Console. ReadLine ();
}
Static void OnWorkflowCompleted (object sender, WorkflowCompletedEventArgs e)
{
WaitHandle. Set ();
// Throw new Exception (\ "The method Or operation is not implemented .\");
}
}
Implementation result
[Img = http://www.microsoft.com/china/MSDN/library/Windev/WindowsVista/art/wwfgetstart_04.png]