Communication between Background Plugin and ViewItem Plugin on client side

Hi,

I would need to share server configuration loading and preparation for multiple ViewItem plugin objects.

Which are the choices in implementing the communication between a common shared Background plugin (running on client side) and many custom ViewItem objects?

I aready know about the Chat sample, but this would need to send/listen to messages.

If I do this at ViewItemUserControl initialization time it could leave its properties in inconsistent status because waiting for replies asynchronously.

This could prevent me to fully initialize the UserControl in a single run, forcing to implement a step by step checklist of replies received to follow before having it fully operational.

Is it possibile to link the ViewItemUserControl directly to the shared Background plugin instance? I would prefer to call its public member functions.

Is there a chance to have it possible by linking back the ViewItemUserControl to its ViewItemPlugin parent and then back to its PluginDefinition parent and doing the same also for the background BackgrounPlugin?

I would store the parent object references at construction time for each object.

So, imagining to have defined the right access properties to parents/childs, I could call BackgrounPlugin member function like this:

reply = viewItemUserControl.ParentViewItemPluginReference.ParentPluginDefinitionReference.OnlyChildBackgroundPluginReference.BackgroundMemberFunction(request)

I know this could become messy in case requests are coming from the opposite direction (from background to viewitem) but I dont need this kind of requests

Assuming the backgroundplugin and the viewitem is in the same project and in the same dll there is many ways to share the data.

An example is actually in the eLearning on MIP SDK Plugins - “Developing MIP SDK Plug-in Integrations”

https://www.milestonesys.com/solutions/services/learning-and-performance/

Hi Bo,

I try to explain my needs.

In the server Admin part of the plugin we create custom items with multiple properties.

In the SmartClient side we need to be able to prepare a combobox and some hashtables reading these items with properties from the server configuration.

These combobox and hashtables are shared among many many plugin-based ViewItems inside the same view or in the same client.

So we need to avoid to recalculate these data from server configuration for each and every ViewItem in the same client (either doing it in ViewItemManager o in ViewItemUserControl or in ViewItemPropertiesUserControl).

These data must be prepared only once, but must be available BEFORE any ViewItemManager for this plugin are created and initialized.

In this way they can be used in ViewItemManager PropertiesLoaded() and then inherited by UserControl and PropertiesUserControl.

PropertiesLoaded function in ViewItemManager needs to be atomic, without any variable initialization deferred through a message system.

Otherwise I would need locks to avoid inconsistency…

If I would load these data through a message system they MUST be asked to a background plugin in the server, otherwise I cannot be sure the background plugin is already ready and running if located on the same SmartClient.

Moreover if using message system I must realize a complex system of locks preventing the Smart Client and the user to access and interact with each ViewItem before the data are fully loaded in the ViewItems and all locks releases.

Can I prepare these data only once in the ViewItemPlugin code, during its initialization?

This object is created only once, by the PluginDefinition object.

According to Class Life Cycle it is initialized AFTER configuration is loaded from server but but BEFORE creating any ViewItemManager.

So this seems to be right place to load and make ready any data shared among each ViewItem beloging to the same Smart Client plugin.

I’m trying to following the road with some new member function implemented inside the ViewItemPlugin class.

In the Init of ViewItemPlugin I’m able to create and fill my fields (eg a Dictionary)

In the Close of ViewItemPlugin I can check my fields are still untouched and I can clear them.

Now the issue is in intermediate callbacks member to propagate these fields values to ViewItemManager. Even if I have a reference to the ViewItemPlugin instance and I call its members I cannot read o return fields with ViewItemPlugin class scope.

Is there any wanted limitation?

The same identical debug log function working in the Init and Close methods is not working when custom method is called by reference from inside ViewItemManager.

I just found I need to make the interesting ViewItemPlugin fields as static!

In such a way they can be propagated to the ViewItemManager both using static member functions and using standard non-static member functions