pglazkov / MvvmValidation

Lightweight library that helps reduce boilerplate when implementing validation in XAML MVVM applications
MIT License
167 stars 31 forks source link

Random long runing validation #4

Closed pglazkov closed 9 years ago

pglazkov commented 9 years ago

Copied from CodePlex: http://mvvmvalidation.codeplex.com/workitem/9

I have a problem with validation in WPF 4.5.1 application. I’m executing ValidateAll on object graph with validation rules on main object with some child collection to validate (in sum 150 validation to calculate on all objects). On random occasions (especially first one) validation takes long time (up to 40 seconds) – I have add measured each rule with Stopwatch and each rule is executing shorter than 1ms (it is only in memory if/linq check) and in sum it takes no more than 100ms (when calculating sum of execution of each rule). When I instrumented app I saw that most of time it waits in

var isCompleted = completedEvent.WaitOne(AsyncRuleExecutionTimeout);

and sometimes even throws timeout exception.

Additionally when I’m compering start time of each rule (I have loged timings in database) I can see that there is some bunch of rules executing in small time window and after that is a couple of seconds window and another bunch of rules executing. It looks like there is some problem with locking/waiting. Is this a known problem? Besides this when executing validation next time it can take 100ms or 40s.