Explore tweets tagged as #SemaphoreSlim
woohoo, an idea I had for my "make SemaphoreSlim not suck" replacement (long story, will blog) turned out to crank all the right dials; very pleased with this - I was aiming for similar perf (but sane behavior in corner case)
2
14
84
How can you lock inside an async method? You'll run into a compiler error if you try using the lock statement. What you can do is use a Semaphore or SemaphoreSlim. There are also many other synchronization primitives available in C#. Two remarks:
6
17
131
Still trying to fix-up a SemaphoreSlim landmine we stumbled into when trying to fix something for @davidfowl - definitely moving in the right direction (assuming it actually works...):
3
1
20
On using the right sync primitives. Just found a case, when switching from `SpinLock` to `SemaphoreSlim` improved the throughput almost 3-x! In this case, we had a bunch of threads, and spinning a lot was detrminental for perf!
1
0
49
A thread-safe, concurrency-friendly implementation of IAsyncDisposable.DisposeAsync without using SemaphoreSlim: https://t.co/arkcyxL3bR Do I even understand this piece I've come up with? 😅 Maybe I should I blog about it. #dotnet #csharp
1
3
5
C# supports locking with the `lock` statement. You can use it to define a code block only one thread can access. However, it doesn't work in an asynchronous context. So you'll have to use some other C# concurrency primitive. - Semaphore - SemaphoreSlim - Monitor - Mutex
2
15
131
Does SemaphoreSlim act as a gatekeeper or as a batchkeeper? https://t.co/GjqiLZhOMd
#csharp #semaphore #asynchronous
0
0
0
Hmm, I told ChatGPT to create a MusicDatabase using C# with ValueTask<T> and ReadOnlySpan<T>. It looked pretty. Then I told it to add concurrency. It decided to use SemaphoreSlim and added an async void method🤔🤔 @davidfowl
2
2
34
Oh wow... SemaphoreSlim.Wait(0) vs CurrentCount == 0 is REALLY slow on .NET Framework.... did not expect such a massive diff. Would checking CurrentCount be open for race conditions if I'm only checking to see if the Semaphore is "signaled" or not? @ben_a_adams @marcgravell
1
0
0
Nito.AsyncEx.LockAsync - Does it work as same as SemaphoreSlim's synchronization? https://t.co/WWfSXiqoVJ
#nitoasyncex #csharp #synchronization #dotnetcore
0
0
0
SemaphoreSlim offers efficient, lightweight synchronization for concurrent systems. Ideal for thread-safe, asynchronous tasks. Have you used it? 🤔 #softwareengineering #csharp #dotnet
1
0
4
Learn SemaphoreSlim with @chaudharyhit! 🎓 It's basically your code's personal assistant, managing tasks smartly to avoid jams & delays. Read more here: https://t.co/kJBSsRugkH
#Dotnet #TechExplained #Csharp #ParallelProgramming #SemaphoreSlim #ResourcePooling
0
23
33
Blogged: "Fun with the Spiral of Death" - the tale of my recent exploits with async code, and in particular SemaphoreSlim:
15
55
153
If you need to control concurrency in your code, the SemaphoreSlim class is one of the simplest solutions in C#. Another option is the new Lock class, but that's available from C# 13. Learn more about locking in C# here: https://t.co/VJoFxOCKnE
5
26
187
Interesting to see the comparison between lock, Interlocked, and SemaphoreSlim.WaitAsync(). lock is faster on .NetFramework, SemaphoreSlim is very much improved on .Net 8
0
1
1
【Qiita】本日のすごい人 [ C# .NET lock SemaphoreSlim Interlocked ]に関する記事を書いた @___sakai__ さん :
0
2
6
Thread/Multithread ve Asenkron/Senkron kavramları ile ilgili notlarımı paylaştığım medium yazı serime devam ediyorum. 4. yazım 'Thread Senkron.;Semaphore ve SemaphoreSlim Notlar' yazım sizlerle. https://t.co/AWfgpkUs4j
#buildinpublic
0
0
1
Programmer Shower Thoughts: Why's it called a SemaphoreSlim and not a Slimaphore?
0
0
1