Windows Workflow Foundation (WF4) - Activity Callbacks and Event Handlers

This sample demonstrates the correct way for a workflow activity to wait for a CLR event from on object.

C# (49.1 KB)
 
 
 
 
 
3.5 Star
(2)
1,639 times
Add to favorites
6/9/2011
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • What's the PROPER way to handle the events?
    1 Posts | Last post July 17, 2013
    • The provided code has multiple issues. It's good for gizmo's only, not for real-life cases. Ron, I guess I don't have to list the issues - you know them.
      
      Is it any plans to add support for events in future. Without it the whole state machine looks like a gimmick. Simply put, if state machine cannot react on external events, like user input, and as so, cannot transition from one state to another - that's not a state machine.
      
      Best regards
      Alex
  • How do i manage two Gizmo's
    1 Posts | Last post October 26, 2012
    • In the workflow, I add an other Trigger branch
      WaitForGizmo.TheGizmo set to Gizmo2
      
      in the program.cs
                  var gizmo = new Gizmo(); 
                  var gizmo2 = new Gizmo(); // <== new one
      ...
                  var input = new Dictionary<string, object>
                                  {
                                      {"TheGizmo", gizmo},
                                      {"Gizmo2", gizmo2} // <== new one
                                  };
      
      ...
                          case 'g':
                              gizmo2.FireGizmo(r.Next(100));
                              break;
      
      I get a runtime error:
      WF4 Callback / Event Sample
         [F]ire Gizmo, [G]izmo2, or [Q]uit:
      
         Workflow Completed with state Faulted (A bookmark with the name 'WaitingForGizmo
      ToBeFired' already exists.)
      
      
      So I need ti name the Gizmo object in stead of using the const name 'WaitingForGizmo'.
      
      
  • Do State Machine Workflows solve this issue?
    2 Posts | Last post October 24, 2011
    • This example is extremely complex...too bad there isn't native support for event handling in workflows. Is this the problem that state machines try to handle (i.e. event-driven paradigm)?
    • The solution would be similar with StateMachine because you would still have to have the extension and create bookmarks.