Fix XMM scanning on Mac x86.
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Validation / ForegroundValidationSynchronizer.cs
1 // <copyright>
2 //   Copyright (c) Microsoft Corporation.  All rights reserved.
3 // </copyright>
4
5 namespace System.Activities.Presentation.Validation
6 {
7     using System.Activities.Validation;
8     using System.Runtime;
9     using System.Threading;
10     using System.Windows.Threading;
11
12     internal sealed class ForegroundValidationSynchronizer<TValidationResult> : ValidationSynchronizer
13     {
14         private TaskDispatcher dispatcher;
15         private Func<ValidationReason, CancellationToken, TValidationResult> validationWork;
16         private Action<TValidationResult> updateWork;
17
18         internal ForegroundValidationSynchronizer(TaskDispatcher dispatcher, Func<ValidationReason, CancellationToken, TValidationResult> validationWork, Action<TValidationResult> updateWork)
19         {
20             Fx.Assert(dispatcher != null, "dispatcher should not be null and is ensured by caller.");
21             Fx.Assert(validationWork != null, "validationWork should not be null and is ensured by caller.");
22             Fx.Assert(updateWork != null, "updateWork should not be null and is ensured by caller.");
23
24             this.dispatcher = dispatcher;
25             this.validationWork = validationWork;
26             this.updateWork = updateWork;
27         }
28
29         internal override void Validate(ValidationReason reason)
30         {
31             this.updateWork(this.validationWork(reason, /* cancellationToken = */ CancellationToken.None));
32         }
33
34         internal override void DeactivateValidation()
35         {
36             // no-op, we do not need to synchronize change since validation is executing on UI thread.
37         }
38
39         internal override void ActivateValidation()
40         {
41             // no-op, we do not need to synchronize change since validation is executing on UI thread.
42         }
43     }
44 }