use AsyncReaderWriterLock inside grain method #8914
Unanswered
slawomirpiotrowski
asked this question in
Q&A
Replies: 1 comment 1 reply
-
It sounds like |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm trying to use AsyncReaderWriterLock inside my grain method. (Microsoft.VisualStudio.Threading.AsyncReaderWriterLock)
Microsoft.VisualStudio's licence is now MIT so we can use it for normal applications too.
AsyncReaderWriterLock is a nice thing to allow fast reader writer lock that is awaitable. I'm trying to use it inside my grain method (my writer is inside the grain while my reader is outside of the grain), but leads to exceptions when using Orleans functions after await for the lock.
It causes InvalidOperationException: Activation access violation. A non-activation thread attempted to access activation services.
Exception is thrown as soon as I try to access State of the grain after await AsyncReaderWriterLock.WriteLockAsync()
I already have a work around: await Task.Run(async () => await _cacheUpdateLock.WriteLockAsync());
But I think it's not how it's supposed to be coded.
I think I am expected to build a JoinableTaskFactory and pass it as argument when creating AsyncReaderWriterLock, but I can't find a way for it to work correctly with Orleans. Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions