Closed mol closed 8 years ago
What's the target platform for this code?
If you need an immediate solution, you can use SemaphoreSlim
(built-in to newer versions of .NET). The syntax is a bit more awkward but it'll get the job done.
Thanks for the fast reply :)
Framework is 4.5.1 and platform is x86. I'm awaiting other stuff, which works fine - just for some reason not this one.
I didn't know the SemaphoreSlim could handle the await inside, but I'll check that out, thanks.
OK, SemaphoreSlim
is available on that platform. It's just a bit more awkward because you have to use try
/finally
instead of using
.
I'll look into this later tonight.
I just tried the AsyncLock from here instead: http://blogs.msdn.com/b/pfxteam/archive/2012/02/12/10266988.aspx
I took everything exactly and not changing anything in your example, and it compiled. I'm using your NuGet package by the way - I don't know if that makes any difference. Strange. Anyway - thanks for looking into it :)
Sorry, I've tried this with a few versions of VS, and I'm not able to repro this behavior.
It's possible that something got messed up during the NuGet install (or something weird happened like it was installed while the project was targeting .NET 4.0). If you could post a minimal repro, I can reopen this issue.
That's alright, thanks for looking into it. I took your suggestion and used SemaphoreSlim instead, so until I need more complex async handling I'm good :) Thanks again.
I copy pasted the AsyncLock example and I'm getting an error message.
The code is: