himo

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 .




Re: Windows Workflow Foundation Erroe in WorkFlow (Idle)

Vishal Kalra - MSFT

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






Re: Windows Workflow Foundation Erroe in WorkFlow (Idle)

himo

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






Re: Windows Workflow Foundation Erroe in WorkFlow (Idle)

Qiang Lin - MSFT

"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"

Do you mean that when you press F5 a third time, the event idle fired, fired again and then again That would be indeed rather strange. By the way, you can config tracing on Workflow so that you can get more information on what is going on.





Re: Windows Workflow Foundation Erroe in WorkFlow (Idle)

Tom Lake - MSFT

The only way that will happen is if you subscribe for the event each time your page loads or the button is click and you don't unsubscribe when the event is received.