Mail to James Conrad

Respected Sir,

I have a problem with the example code for ASP.net Workflow example which was given in the Windows Workflow offcial site

privatevoid StartWorkflow()

{
// Define the parametes for the

Dictionary<string,object> parameters =newDictionary<string,object>();

parameters.Add("FirstName", txtFirstName.Text);

parameters.Add("LastName", txtLastName.Text);

WorkflowRuntime workflowRuntime =WorkflowRequestContext.Current.WorkflowRuntime;

// Attach to the WorkflowCompleted event

workflowRuntime.WorkflowCompleted +=

newEventHandler<WorkflowCompletedEventArgs>(WorkflowRuntime_WorkflowCompleted);

// Start the Workflow1

WorkflowInstance workflowInstance = workflowRuntime.StartWorkflow(

typeof(WorkflowLibrary1.Workflow1), parameters);

}

void WorkflowRuntime_WorkflowCompleted(object sender, System.Workflow.Runtime.WorkflowCompletedEventArgs e)

{

this.lblResults.Text = e.OutputParameters["Results"].ToString();

}

in this ASP.net workflow example which was given in windows workflow official site,

After running the code, we are not getting results in the "lblResults", the event WorkflowRuntime_WorkflowCompleted was not fired.

the code execution is not going into this block.

Is it necessary that we must use datapipes to get back the information from the workflow to the ASP.net application.

Can you give me the reason for this why the code is not executing.

Thanking You,

Sekhar Ragu

[3259 byte] By [SekharGermany] at [2007-12-17]
# 1
I am probably stupid or something but I can't find this ASP.NET WWF example, can somebody provide me with a link?
phatrice93 at 2007-9-9 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2
http://www.windowsworkflow.net/default.aspx?tabindex=4&tabid=41
scroll down to the end of the page, u can find it
bangaram at 2007-9-9 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3

It's tough to say why the code is not executing. It's a pretty simple example, so I'm suprised there are any problems with it. Just to ask the obvious, do the projects compile fine?

Also, did you create the WorkflowTracking, WorkflowTimer, and WorkflowPersistence databases needed by the sample? The scripts for creating tem againist SQLExpress are located in the \SQL Database Scripts directory. The instructions are in the readme.mht file.

Let me know if this doesn't address your question.
James Conard
Architect Evangelist - Windows Workflow Foundation
http://www.WindowsWorkflow.net
http://blogs.msdn.com/jamescon

JamesConard at 2007-9-9 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4

Here's the URL and information about this specific example:
ASP.NET Workflow Example
This simple example demonstrates how to use the Windows Workflow Foundation within an ASP.NET WebForm.

Download Now (Last Updated: Saturday 10/07/2005) Created By: James Conard
There's also an ASP.NET help-desk application that demonstrates how to use some custom read/write data activities:

Help Desk Support - Windows Forms & ASP.NET Web Forms Applications
The Help Desk support application demonstrates how to the custom Read Data and Write Data activities to exchange data with the host application. There are two version of the application: a Windows Forms version and an ASP.NET Web Forms version. Both versions of the application use the same workflow.

Download Now (Last Updated: Tuesday 10/11/2005) Created By: Israel Hilerio
James Conard
Architect Evangelist - Windows Workflow Foundation
http://www.WindowsWorkflow.net
http://blogs.msdn.com/jamescon

JamesConard at 2007-9-9 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5

Thank u James for the answer, I have one more doubt, this (ASPNetWorkflowexample) code is working properly, the same program I have written in Windows Forms, I am getting a cross thread operation exception, when i am going to display the result in the textbox.

Can you give me some tips how to Avoid Cross thread operations with windows forms.

bangaram at 2007-9-9 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6
bangaram wrote:

Thank u James for the answer, I have one more doubt, this (ASPNetWorkflowexample) code is working properly, the same program I have written in Windows Forms, I am getting a cross thread operation exception, when i am going to display the result in the textbox.

Can you give me some tips how to Avoid Cross thread operations with windows forms.

I assume that you're updating the textbox in the event handler for the WorkflowCompleted event? The issue is that the event handlers are executed on a different thread than the UI. To address this issue, you need to use the Invoke method of the TextBox control to invoke a method on the UI thread. The Ordering State Machine example at http://www.WindowsWorkflow.net/downloads demonstrates how to do this when the state for the workflow changes.

Here's the code snippet. The UpdateListItem method you see here is called by the StateChanged event handler.


private delegate void UpdateListItemDelegate(WorkflowInstance workflowInstance, string workflowState, string workflowStatus);


private
void UpdateListItem(WorkflowInstance workflowInstance, string workflowState, string workflowStatus)

{

if (this.lstvwOrders.InvokeRequired)
{
// This code is executing on a different thread than the one that
// ...created the ListView, so we need to use the Invoke method.
// Create an instance of the delegate for invoking this method
UpdateListItemDelegate updateListViewItem =
new UpdateListItemDelegate(this.UpdateListItem);

// Create the array of parameters for this method
object[] args = new object[3] { workflowInstance, workflowState,
workflowStatus };

// Invoke this method on the UI thread
this.lstvwOrders.Invoke(updateListViewItem, args);

}

else
{
// Get the ListViewItem for the specified WorkflowInstance
string instanceId = workflowInstance.InstanceId.ToString();
ListViewItem lvitemOrder = lstvwOrders.Items[instanceId];

if (lvitemOrder == null)
{
return;
}

// Update the Workflow State & Status column values
lvitemOrder.SubItems[OrderStateColumnIndex].Text = workflowState;
lvitemOrder.SubItems[WorkflowStatusColumnIndex].Text = workflowStatus;
}
}



James Conard
Architect Evangelist - Windows Workflow Foundation
http://www.WindowsWorkflow.net
http://blogs.msdn.com/jamescon


JamesConard at 2007-9-9 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified