Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Real World Examples of WF and WPF Interaction

I'm looking for some good real-world examples of interaction between Windows Presentation Foundation and Workflow Foundation. Most of the WF tutorials I see demonstrate use within console applications. I'm more curious about applications that use a rich WPF interface and WF. Particularly if they allow user defined workflows (allow users to design and run their own workflows on the fly).

like image 735
KrisTrip Avatar asked Feb 15 '11 19:02

KrisTrip


2 Answers

I'm not sure what exactly you're looking for, but here are some links to information about actual real world applications using Workflow in desktop (WPF) applications in one way or another:

  • Sample Real World WF4 Integration
  • Infinity Workflow (there's a lot of info in the linked Word file)
  • Aderant Enterprise Workflow (also presented at PDC Windows Workflow Foundation Futures session)
like image 107
Damir Arh Avatar answered Nov 02 '22 07:11

Damir Arh


Let me take the example of trying to make two workflows communicate with each other.

  1. First you need to write a host. This is an extremely loaded proposition, because for two WF hosts to talk to each other, you will then also need to know WCF, and all mushy concepts of threading.
  2. Then your WF will need to communicate with other WFs via the hosts. This makes sense because a WF doesn't keep running in memory for 3 months, when it is waiting for another WF to send an event. The WF sits in the database, and the communication occurs through the hosts.
  3. Okay, even for simpler scenarios, for local in-process communication, you have the CallExternalMethod activity, and HandleExternalEvent activities. Even in this case, you have to talk via the host, because the WF might have been passivated to the database. So in order to do so, you have to remember to do 3 things, decorate your interface with the ExternalDataExchangeAttribute, eventargs needs to derive from ExternalDataEventArgs, and event args is serializable.
  4. If you mess up in any of the items in #3, you get a very non-intuitive "InvalidOperationException". Sure the message says, "Service does not implement an interface with the ExternalDataExchange attribute", but it isn't until you look at the inner exception, that you really know what happened - i.e. you forgot to make it serializable. doh! But I did mark it as serializable. Actually, everything needs to be serializable, even the sender.
  5. Then you have to connect the WF activities, via the proper interface names and method names you are using to communicate.
  6. Finally, for even in-process WF communication, you have to remember to add your service to the ExternalDataExchangeService, and not the WF runtime. Otherwise, it will look like nobody is subscribing to the event. Not to mention, that this is one of those bug, that doesn't really throw an error. i.e. hard to track down!

So, in short, for the simplistic scenario of trying to make two workflows communicate, you need to have a good handle on the following:

*Writing windows apps (for the host), *Threading, *WCF, *OOP Concepts, *All concepts of serialization, *Plenty of hooking up and non-intuitive details of WF itself, *Ninja debugging skills.

Source:http://blah.winsmarts.com/2008-2-I've_been_here_before.aspx

like image 24
Kings Avatar answered Nov 02 '22 09:11

Kings