Commit cd8abf7
committed
Use Task.Run for async validation methods to improve thread utilization
- Changed from Task.FromResult to Task.Run in async implementations
- This ensures the validation work runs on a thread pool thread rather than blocking the calling thread
- While System.ComponentModel.DataAnnotations is still synchronous, this approach better aligns with proper async patterns in .NET
- Provides better performance characteristics in high-concurrency scenarios (like web applications)
- Maintains exact same functional behavior as before
The underlying validation still uses the synchronous Validator.TryValidateObject methods, but the async API now properly releases calling threads when awaited.1 parent a8007a7 commit cd8abf7
File tree
1 file changed
+4
-4
lines changed- src/RecursiveDataAnnotationsValidation
1 file changed
+4
-4
lines changedLines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
0 commit comments