"Element loaded" event not being fired


Event launch points on the "Element Loaded" fail to be fired. Using version

The reason seems to be in the timing of the deserialization and the wiring of the event handlers.

The store is loaded at https://github.com/NuPattern/NuPattern/blob/master/Src/Runtime/Source/Runtime.Core/PatternManager.cs#L239, with the DSL model triggering the creation events which are interpreted as Instantiation or Loading events at https://github.com/NuPattern/NuPattern/blob/master/Src/Runtime/Source/Runtime.Store/DomainModel/ProductState.cs#L243-278. However, it's only after the store was loaded that the pattern manager is hooked up to the store's events at https://github.com/NuPattern/NuPattern/blob/master/Src/Runtime/Source/Runtime.Core/PatternManager.cs#L253-258, and there is no event buffering in place storing these store events so they are triggered once the pattern manager is hooked up, causing the events to be lost.

It's possible wrapping the loading of the store with an event buffering scope takes care of this issue.

Attached a sample repro project. Run it, create a new instance of the toolkit, reopen the solution and you will see automation does not fire, but works fine when triggered from a context menu.

file attachments


jezzsa wrote Aug 4, 2014 at 6:29 PM

Thanks fernando,

This explains a few things I've been noticing over the years. we should definitely fix this.