Hosting workflow in a Windows Form
In this task we will create a workflow running in a Windows Form application.
How to do it...
Create a Windows Form project:
Create a Windows Form project and name it
HostingWorkflowInWinForm
.Create a workflow:
Add a workflow to the project and call it
AdditionWorkflow.xaml
. Author the workflow like this:Create a Windows Form.
Open the default created
Form1.cs
file and alter it to:Double-click the Adding button and add code to the button event handler. The final code will be:
using System;using System.Windows.Forms;using System.Threading;using System.Activities;namespace HostingWorkflowInWinForm {public partial class Form1 : Form {public Form1() {InitializeComponent();}private void buttonAdding_Click(object sender,EventArgse) {AutoResetEventwaitHandler = newAutoResetEvent(false); string result = "";AdditionWorkflowaddwf = new AdditionWorkflow {x = new InArgument<Int32>(Int32.Parse(textBoxX.Text.ToString())),y = new InArgument<Int32>(Int32.Parse...