Events not firing when switching from local dataportal to WcfProxy

Events not firing when switching from local dataportal to WcfProxy

Old forum URL: forums.lhotka.net/forums/t/6536.aspx


Joffies posted on Sunday, March 01, 2009

Hello weekenders! :)

I have a BusinessBase class with a public event to which a ReadOnly list subscribes.

When using local dataportal my event fires just fine but when switching from local dataportal to WcfProxy the event does not fire.

Is there anything specific that needs to be configured in WCF to make custom events fire?

Thanks

 

RockfordLhotka replied on Sunday, March 01, 2009

There are two things.

First, events won't flow across WCF from server to client (or visa versa) by default. Only very specific WCF channels, and some extra coding to support callbacks, will enable that to occur. And even if you do that, you must realize the scalability impact of such an implementation.

Second (and I suspect what you are asking), is that when an object graph passes through the data portal all event hookups are typically lost. WCF simply doesn't preserve event hookups, and that's that.

To overcome this, you need to override OnDeserialized() in the parent object and rehook any events to the child object. Or in your case, the ROL needs to override OnDeserialized() to rehook  the handler to the BB object.

If your ROL isn't being serialized across the wire (because it is a cache or something like that), things get more complex. In this case there's typically one ROL in memory, and many BB objects come and go over time. So the ROL needs to somehow know when any of the BB objects have been saved.

The Saved event on BB might be more helpful in this case, though you'll need to implement some sort of registration (and deregistration) process so each BB can tell the ROL to start and stop listening for the Saved event.

This is a pub/sub model, and can be implemented using the Observer design pattern.

Copyright (c) Marimer LLC