Random long runing validation


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.
Closed Nov 10, 2015 at 8:56 PM by pglazkov
Fixed on GitHub. The fix is included in the 2.1.0-beta NuGet package: https://www.nuget.org/packages/MvvmValidation/2.1.0-beta


pglazkov wrote Nov 6, 2015 at 2:41 PM