Asynchronous Rule Question - CSLA 4

Asynchronous Rule Question - CSLA 4

Old forum URL:

mosgath posted on Monday, January 03, 2011

I am new to CSLA and working in CSLA 4.  What is the best way to implement a rule that triggers asynchronously for a property and that passes all properties of the property's parent to the command that is triggered?

I have gone the path of creating a Rule object that calls a Command Object asynchronously (using DataPortal) and setting a property on the command object equal to the business object using the RuleContext.Target.  However, since the IsAsync property on the rule is set to true, the Target property is null on the client side and the property on the Command object will not be valid.

The entire contents of the parent object is required by a third party service that is being called by the Command Object to perform the validation.  I have multiple types of validations that require this.

Would this be a place to use the ProvideTargetWhenAsync=True or is there a better way? 



JonnyBee replied on Monday, January 03, 2011

If you need the entire object then yes - you should set ProvideTargetWhenAsync = true.

This will make the  rule engine supply the context.Target property to the async rule.

If you are going to set any out values in the business object (other than result) then use OutputValues.


mosgath replied on Monday, January 03, 2011

Thanks JonnyBee. 

JonnyBee replied on Tuesday, January 04, 2011

Just one more thing you must be aware of:

In Async rules - Your code must call context.Complete in the async callback (or sync code that does not start an async operation).

Otherwise the RuleEnginge will consider the Async opertion is still running, the field is still busy and you cannot set a new value into that field !!

Copyright (c) Marimer LLC