This project is read-only.
1

Closed

Async rule locking up UI thread

description

Hi,

I've just downloaded the latest version and tried a simple async rule such as below:

Validator.AddAsyncRule(() => Product, () => Task.Factory.StartNew(()=>
                                                                           {
                                                                             System.Threading.Thread.Sleep(TimeSpan.FromSeconds(2));
                                                                             return RuleResult.Invalid("Wrong produt");
                                                                           }));
The UI thread remains locked up for 2 seconds. Looks like it's waiting on the Error property to return a result as per below call stack:
WindowsBase.dll!System.Windows.Threading.DispatcherSynchronizationContext.Wait(System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout) + 0x29 bytes 
[Native to Managed Transition]  
[Managed to Native Transition]  
MvvmValidation.dll!MvvmValidation.ValidationHelper.GetResultInternal() + 0x70 bytes 
MvvmValidation.dll!MvvmValidation.DataErrorInfoAdapter.Error.get() + 0x10 bytes 
BTW I'm using .NET 4.0 and WPF.

I have also noticed a similar behaviour in the sample app. I start changing the user name to trigger the async validation and sometimes the UI locks up for an instant.

Any suggestions?

Regards.
Closed May 18, 2014 at 1:18 PM by pglazkov
Fixed. The updated binary can be downloaded from here: https://mvvmvalidation.codeplex.com/downloads/get/814269

comments