![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | WWF - Cancels an activity execution when an exception occurs Hey folks. This question is about Windows Workflow Foundation and exception handling. I have a HandleExternalEventActivity activity that runs some code when the user clicks an "Accept" button on my form. The activity includes several tasks that involves database and eventually filesystem. The problem is, when an exception occurs within that activity, the workflow is set to Terminated. That ruins the flow, because even if I can trap the exception (throw to the host) , the user will not be able to click the Accept button anymore, because the workflow state will be erased. In short, is there a way to catch the exception inside the activity and return it like if it was never called? (same as a rollback). I tested FaultHandlers, not good. And I have searched a lot, but can't find this "activity rollback" behaviour. I appreciate help. ![]() *Ps*.: just to know the way of working, I wish this: 1. user clicks accept button; 2. wwf throws an exception; 3. the host application traps and tells user to fix whatever data is wrong; 4. user clicks accept again; 5. wwf continues to trhow exception till everything is ok. If all ok, commit the regular way long. Cesar |
My System Specs![]() |
| | #2 (permalink) |
| | Re: WWF - Cancels an activity execution when an exception occurs You can look into compensation that work with or without FaultHandlerActivity: CompensatableSequenceActivity and CompensateActivity (but do not confuse the two). Or even just FaultHandler would do it (assume it is a sequencial workflow): you place the EventDrivenActivity's container (a ListenActivity?) in a WhileActivity loop, and set a flag in the workflow to indicate whether "Accept" process is done successfully or not, the workflow will be in a loop to listen the "Accept" event until "Accept" process is done. If the exception happens, the FaultHandler catch it (so that your workflow is not terminated), the ListenActivity is done, but the "Accept" flag is not set, so the workflow will loop back due to WhileActivity. Of course you may want to have some sort of notification if the "Accept" process repeatedly throws out exception (or the user knows to whom he/she should report for this failure), so that your workflow would not be stuck there. "Cesar" <nospam@xxxxxx> wrote in message news:%238XOp8%23qJHA.4592@xxxxxx Quote: > Hey folks. > > This question is about Windows Workflow Foundation and exception handling. > > I have a HandleExternalEventActivity activity that runs some code when the > user clicks an "Accept" button on my form. The activity includes several > tasks that involves database and eventually filesystem. > > The problem is, when an exception occurs within that activity, the > workflow is set to Terminated. That ruins the flow, because even if I can > trap the exception (throw to the host) , the user will not be able to > click the Accept button anymore, because the workflow state will be > erased. > > In short, is there a way to catch the exception inside the activity and > return it like if it was never called? (same as a rollback). > > I tested FaultHandlers, not good. And I have searched a lot, but can't > find this "activity rollback" behaviour. > > I appreciate help. ![]() > > *Ps*.: just to know the way of working, I wish this: > 1. user clicks accept button; > 2. wwf throws an exception; > 3. the host application traps and tells user to fix whatever data is > wrong; > 4. user clicks accept again; > 5. wwf continues to trhow exception till everything is ok. If all ok, > commit the regular way long. > > > Cesar > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: WWF - Cancels an activity execution when an exception occurs Hmmm... I was trying to escape from setting a loop to fix that, for the reason not turning the workflow too complex (I have about 8 ListenActivities on it). But since it seems there are no simpler manner to do it, then I'll go for it. Thanks! Cesar PS: Btw, its a confuse logic to follow. The expected way to work would be: "if something was wrong, lets cancel it". And not "if something was wrong, lets continue the work, as it was not important". Any way to suggest an improvement to wwf team? "Norman Yuan" <FakeName@xxxxxx> wrote in message news:eygGZ2IrJHA.1748@xxxxxx Quote: > You can look into compensation that work with or without > FaultHandlerActivity: CompensatableSequenceActivity and CompensateActivity > (but do not confuse the two). > > Or even just FaultHandler would do it (assume it is a sequencial > workflow): > > you place the EventDrivenActivity's container (a ListenActivity?) in a > WhileActivity loop, and set a flag in the workflow to indicate whether > "Accept" process is done successfully or not, the workflow will be in a > loop to listen the "Accept" event until "Accept" process is done. If the > exception happens, the FaultHandler catch it (so that your workflow is not > terminated), the ListenActivity is done, but the "Accept" flag is not set, > so the workflow will loop back due to WhileActivity. Of course you may > want to have some sort of notification if the "Accept" process repeatedly > throws out exception (or the user knows to whom he/she should report for > this failure), so that your workflow would not be stuck there. > > "Cesar" <nospam@xxxxxx> wrote in message > news:%238XOp8%23qJHA.4592@xxxxxx Quote: >> Hey folks. >> >> This question is about Windows Workflow Foundation and exception >> handling. >> >> I have a HandleExternalEventActivity activity that runs some code when >> the user clicks an "Accept" button on my form. The activity includes >> several tasks that involves database and eventually filesystem. >> >> The problem is, when an exception occurs within that activity, the >> workflow is set to Terminated. That ruins the flow, because even if I can >> trap the exception (throw to the host) , the user will not be able to >> click the Accept button anymore, because the workflow state will be >> erased. >> >> In short, is there a way to catch the exception inside the activity and >> return it like if it was never called? (same as a rollback). >> >> I tested FaultHandlers, not good. And I have searched a lot, but can't >> find this "activity rollback" behaviour. >> >> I appreciate help. ![]() >> >> *Ps*.: just to know the way of working, I wish this: >> 1. user clicks accept button; >> 2. wwf throws an exception; >> 3. the host application traps and tells user to fix whatever data is >> wrong; >> 4. user clicks accept again; >> 5. wwf continues to trhow exception till everything is ok. If all ok, >> commit the regular way long. >> >> >> Cesar >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Exception stack is corrupt when catching and storing the exception | .NET General | |||
| Vista Install Error: Exception Unknown Software Exception | Vista installation & setup | |||
| Installation cancels becasue of system volume | Vista installation & setup | |||
| Gathering Files Cancels @32% | Vista General | |||
| Upgrade Check incorrectly reports McAfee exists and cancels upgrad | Vista installation & setup | |||