Erroe in WorkFlow (Idle)

I have my Asp.Net Application :

when i press the button the first state in done and then the work flow fired the event idle and every thing is ok .

"operation Sucess " .

then i press again on the button ......the WorkFlow Idle if fired twice .continously

if i press the third time ......the work flow fired idle event " three times continously "

why ???

how can i solve it .

[451 byte] By [himo] at [2008-1-10]
# 1

Could you explain how workflows and ASP.net are being used together in your scenario? How is the workflow runtime configured, are you using a state machine or a sequential workflow, how does host application communicate with the workflow, are you using a persistence service?

VishalKalra-MSFT at 2007-10-3 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2

Hello dear ,

Thanks for ur reply ,

ok i will tell u how I use My work Flow :

First : I create run time in my Global File :

protected void Application_Start(object sender, EventArgs e)

{

// creat new workflowruntime

WorkflowRuntime workFlowRuntime = new WorkflowRuntime();

// add ManualWorkflowSchedulerService

ManualWorkflowSchedulerService manualService = new ManualWorkflowSchedulerService();

workFlowRuntime.AddService(manualService);

// Add the External Data Exchange Service

ExternalDataExchangeService dataservice = new ExternalDataExchangeService();

workFlowRuntime.AddService(dataservice);

// Add a new instance of the OrderService to the External Data Exchange Service

OrdersService service = new OrdersService();

dataservice.AddService(service);

//Add SqlPersistenceService

workFlowRuntime.AddService(new SqlWorkflowPersistenceService(System.Configuration.ConfigurationSettings.AppSettings["EpaymentConnectionString"]));

//start workFlowRunTime

workFlowRuntime.StartRuntime();

// set workFlow for an application

Application["WorkflowRuntime"] = workFlowRuntime;

}

protected void Application_End(object sender, EventArgs e)

{

WorkflowRuntime workFlowRuntime = Application["WorkflowRuntime"] as WorkflowRuntime;

// stop workflow runtime

workFlowRuntime.StopRuntime();

}

-

second : in my page Form I write this code :

protected void Page_Load(object sender, EventArgs e)

{

if (!Page.IsPostBack)

{

try

{

StartWorkFlow();

_workFlowInstanceId = GetworkFlowInstanceId(_pageContent);

if (_workFlowInstanceId != Guid.Empty)

{

_service.RaiseRecievedEvent(new OrdersEventArgs(_workFlowInstanceId));

_manualScheduler.RunWorkflow(_workFlowInstanceId);

}

else

{

Response.Write("Unexpected error");

}

}

catch

{

Response.Write("Unexpected error");

}

}

private void StartWorkFlow()

{

try

{

_workFlowRunTime = Application["WorkflowRuntime"] as WorkflowRuntime;

_manualScheduler = _workFlowRunTime.GetService<ManualWorkflowSchedulerService>();

_service = _workFlowRunTime.GetService<OrdersService>();

sqlservice = _workFlowRunTime.GetService<SqlWorkflowPersistenceService>();

//create EventHandler for a workflow runtime

_workFlowRunTime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(WorkFlowrunTime_Terminated);

_workFlowRunTime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(WorkFlowrunTime_Idled);

_workFlowRunTime.WorkflowSuspended += new EventHandler<WorkflowSuspendedEventArgs>(_workFlowRunTime_WorkflowSuspended);

}

catch

{

_summerryLabel.Text = "UnExpected Error";

}

}

private Guid GetworkFlowInstanceId()

{

try

{

//create instance work flow

_workFlowInstance = _workFlowRunTime.CreateWorkflow(typeof(BLL.WorkFlow.TransactionWorkflow));

//start WorkFlow

_workFlowInstance.Start();

Hidden1.Value = _workFlowInstance.InstanceId.ToString();

//return instanceId

return _workFlowInstance.InstanceId;

}

catch

{

return Guid.Empty;

}

}

private void WorkFlowrunTime_Terminated(object sender, WorkflowTerminatedEventArgs e)

{

_summerryLabel.Text = e.Exception.Message;

}

private void WorkFlowrunTime_Idled(object sender, WorkflowEventArgs e)

{

//upload workflow from memory to database

_workFlowInstance.Unload();

}

Now in the form Load I start my work Flow And i raise event to start first state ,,,,and the work Flow idle Works once ....then i press F5 "Frfresh" the form load start and raise event again but the event idle fired twice Contiuously .......if I press F5 as a third time ...the event idle fired three times Contiuously

thanks

hema

himo at 2007-10-3 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified