C
C#

Nito.AsyncEx vs DotNext.Threading

Nito.AsyncEx vs DotNext.Threading

MMarkusSchaber11/20/2023
We're currently searching for a nice AsyncAutoResetEvent implementation. We found two suitable implementations: Nito.AsyncEx: https://github.com/StephenCleary/AsyncEx/blob/master/doc/AsyncAutoResetEvent.md DotNext.Threading: https://dotnet.github.io/dotNext/api/DotNext.Threading.AsyncAutoResetEvent.html Is there any comparison between those, or between the two libraries in general? (PS: We do not want to use the Microsoft.VisualStudio.Threading implementation of AsyncAutoResetEvent, as that package pulls in analyzers which just don't apply in our environment, as our project is not a VS extension.)
Qqqdev11/20/2023
Hm, we are using the MS nuget package you mentioned You can also use it in non-VS extensions I don't think there is a way to get rid of the analyzers but you could always silence them. We suppressed two of the rules, the rest seemed pretty solid for our use case (backend service)
F333fred11/20/2023
It's important to note that the vsthreading analyzers are much more general than vs. The name isn't good, I agree, but they're for more than it implies
MMarkusSchaber11/21/2023
The most annying one is the one which requires all async xunit test methods to have the ...Async suffix in their name. While we prefer this name convention for normal code, we do not want it in test methods, as the Async is a detail of the test implementation and should not appear in reports, and the test identifier should not change just because the implementation now needs to use async. Other analyzers have an exception for those test methods. Another annoying one is the analyzer which suggests to use JoinableTaskFactory when accessing Task.Result, even if it's in an if block where Task.IsComplete is checked. And, as far as I can see, the JoinableTaskFactory has quite some overhead, which is required in a WPF or WinForms Environment with a primary thread, but doesn't make sense in a ThreadPool environment like ASP.NET Core. There was some other cases which we didn't like but they were single occurrences. What annoys us most is that the implementation package pulls in the analyzer unconditionally - our policy prefers to explicitly decide about the rule set. So we started looking for alternatives, and both mentioned above seem to be stable and maintained.
Qqqdev11/21/2023
Yeah, we suppressed the first rule you mentioned Couldn't you just use the MS nuget package and literally suppress every rule?
MMarkusSchaber11/21/2023
I guess we could. However, some guys in the QA area are a bit picky about suppressing rules, we need to give justifications. And it's inefficient to run analyzers just to completely ignore them. šŸ™‚ I wonder what drove the maintainers to implicitly pull in the analyzers, instead of providing them optionally (as e. g. xUnit Analyzers do).
Qqqdev11/21/2023
True, not really a big fan of that either. I assume that decision was appropriate for their MS projects https://github.com/microsoft/vs-threading/issues/605#issuecomment-611215842
MMarkusSchaber11/21/2023
Ouch. We also use StreamJsonRpc. That might mean replacing the library above may not actually solve the problem. šŸ„“
F333fred11/21/2023
We don't run the analysis if they can't produce observable results, fwiw (roslyn doesn't, I mean, in case that wasn't clear)
MMarkusSchaber11/29/2023
Next case:
VSTHRD003: Avoid awaiting or returning a Task representing work that was not started within your context as that can lead to deadlocks. Start the work within this context, or use JoinableTaskFactory.RunAsync to start the task and await the returned JoinableTask instead.
As far as I can see, this only applies in single threaded environments like Windows Forms or WPF, not in a free threaded environment running on the thread pool. And we sometimes store or pass some tasks around, as a kind of "promise" for a future result of an operation. For your info: we will go with suppressing the warnings now, as we cannot easily get rid of the dependency anyways.

Looking for more? Join the community!

C
C#

Nito.AsyncEx vs DotNext.Threading

Join Server
Want results from more Discord servers?
Add your server
Recommended Posts
Sequential BlinkersHello everyone! I bought these sequential blinkers that run off an stm32 blue pill board. the only pTrying to use Microsoft.Kiota namespace but not found when importingI am trying to use this method from the Microsoft.Kiota.Abstractions.Extensions namespace: ToFirstChWinUI3 Scheduler CalendarViewhello im trying to make a winui3 calendarview interactive calendar where I can predefine dates in myThe call is ambiguous between the following methods or properties: 'Thread.Thread(ThreadStart)' andi have to upload by filesHelp a noobie out with a simple hangmanHi! New to coding and I need some help to solve this problem. Shall I save the words to a list? AnyC# Image Resizing on Visual Studio CodeI've tried both ``newPic.SizeMode = PictureBoxSizeMode.StretchImage;`` and ``newPic.SizeMode = PictuI'm stuck,visual studio 22, I need help making my invaders/enemies move left to right then downIā€™m trying to get my invaders/enemies to move left to right then down like in the game space invaderāœ… Where should I store all the sensitive file on .NET project?Hello everyone, May I know where should I store all the credential files that needs to be used by .Unity CodeI have been trying to get my C# code to work in unity for about a week and I am officially lost. I'vHelp! Reporting service in dotnet Core?please don't mind my english, it is not that good. i have created 2 projects one is server -dotnetCatAPI Json deserialization issue.I'm having trouble getting my code to deserialize my json correctly. When I run my Program.cs I get āœ… Any idea why I cant use sendkey?Authorization in microservices archHello everyone, I'm quite new to the NET microservices arhitecture and right now I'm implementing a.āœ… I can't get my runButton button to work on a windows form app```cs if (e.KeyCode == Keys.Enter || (e.Modifiers == Keys.None && sender == runButton)) ``` I can sGit and Google Drivenew git user.. it seems to have your local repositories in a google drive controlled file structure ASP.NET CRUD MODALI created a MVC controller with actions (CRUD) and I would like to know, how to modify this pre geneErrorāœ… using from another csprojCurrently i have 2 projects, an api app and a worker service app And both use the same models. Is thJavascript not working on my MVC projectI'm learning front end tutorials at the moment so I'm totally new to designing websites. _Layout.csis there a way to get the colocation center connected to with C# ?I wanna get information about the colocation center exactly how Cloudflare warp gets it in the prefe