-
When I convert my project to asynchronous,
And the compiler doesn't show a warning or an error. I think runtime as a core library, you can't make yourself code don't work well with yourself code, every class in the core library should work well in the asynchronous function. So in order to make the system more robust, the code such as ReaderWriterLockSlim should be improved or be obsoleted. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 11 replies
-
Hello @lbgitjp, synchronous-only synchronization primitives like |
Beta Was this translation helpful? Give feedback.
-
Making This is true for most synchronization primitives in
When you're porting a synchronous code base to Making these 'old' synchronization primitives obsolete doesn't make sense. They're still perfectly functional and useful in synchronous code. By the way, replacing |
Beta Was this translation helpful? Give feedback.
-
I think almost everyone's project will be converted to asynchronous one day, just like me, because almost every project will use one If they do convert, the complier show no error, just ok,their projects seems run good, but their project actually have potential problems. Mark the asynchronous incompatible code obsolete, the users still can use it, but prompts them, they use some bad code. By mark the asynchronous incompatible code obsolete, you encourage users to use asynchronous code as much as possible, do not use synchronous code. |
Beta Was this translation helpful? Give feedback.
-
Synchronous code is what builds asynchronous code, without .NET's help, you can still build your own asynchronous little state machine in c++ or assembly. Synchronous code is less complex due to the lack of such state machine |
Beta Was this translation helpful? Give feedback.
-
The only thing that's actually a problem is thread-affine locks, and only if you're holding a lock and call
Async code is never guaranteed to run on more than one thread, outside of scenarios that explicitly start a new |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Making
ReaderWriterLockSlim
usable in asynchronous context is not possible. Even if you ignore the fact that its API surface is inherently thread-affine, there is still the issue that its locking semantics are defined to be thread-affine and changing that would be breaking.This is true for most synchronization primitives in
System.Threading
;SemaphoreSlim
is an exception. Unlike the others, its documentation explicitly states:When you're porting a synchronous code base to
async
/await
, you have to very carefully audit any use of synchronization primitives.Making these …