Communicate to host
There are different ways to communicate with the host application that is running the rules. One of these is to create and raise an event and let the host application handle it ActiveElementCallback via the ProcedureEngine.
HostCallBack allows you to create an event and propagate it to the host application. The host application is the code that is running the rules. It can either be on the client or server side.
How it works
This mechanism allows rules to communicate with the outside world by sending and receiving the required information and data for processing. When an execution reaches the command, its engine will raise an event (ActiveElementCallback). If the host application has handled the event, it will be able to respond to the event.
While raising the event inside of the rule, Tag setting of the command may carry more information to the host application. Then, the host application Response property of the CallbackEventArgs can be set. After event handling is finished, the execution of the rule continues. And the rule will be able to retrieve data by setting responseRef to some local parameters for later use. The key setting of the command allows the rule to send a decision key to the host application. Then the application will be able to respond to the event based on the set key.
<Procedure name="HostCallBackSample" enabled="true">
<Define name="userName" direction="In"/>
<Define name="userRole" direction="local"/>
<HostCallback tagValue="userName" key="askUserRole" responseRef="userRole"/>
// Create your engine from a procedure execution plan named 'proc'
ProcedureEngine engine = CreateEngine(proc);
// Handles callback event of engine
engine.ActiveElementCallback += engine_ActiveElementCallback;
And later on you have the event handler:
void engine_ActiveElementCallback(object sender, CallbackEventArgs e)
// you can decide based a tag value
if (e.Tag != null)
// e.g. loopup for user role
// set the response, then the rules will store the value in a processing context
e.Response = "Admin";