ViewModelBase performance, solution

ViewModelBase performance, solution

Old forum URL:

mesh posted on Monday, June 17, 2013

I'm experiencing some terrible performance with ViewModelBase (WPF) class. If changing Model properties or adding items to list, profiler is returning results that are hundreds of times slower then expected. I figured out that such performance is because of events attached in HookChangedEvents method?

Solution may be to implement some disposable class, eg. BypassChangedEvents wich will wrap UnhookChangedEvents, HookChangedEvents and OnSetProperties.

After that code that is changing Model may look like:




using (BypassChangedEvents)
// Model.Property = something;
// Model.Child.Add(item);
// ...

RockfordLhotka replied on Monday, June 17, 2013

What events are you talking about? Custom events, or standard PropertyChanged events?

mesh replied on Tuesday, June 18, 2013

Standard PropertyChanged and ChildChanged events.

Copyright (c) Marimer LLC