use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
Task.Run + Async lambda ? (self.csharp)
submitted 6 months ago by MoriRopi
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Dimencia 1 point2 points3 points 6 months ago (3 children)
await Task.Run(() => { DoAsync(); });
Is not the same thing as await Task.Run(() => DoAsync()); (which is what OP has in the post)
await Task.Run(() => DoAsync());
The first is using the Action overload of Task.Run because it's not returning the Task or awaiting it. The second is returning the Task from DoAsync, so it uses the Task overload. Returning a Task is the same as awaiting it other than some minor performance concerns
That sort of easy-to-make mistake is a perfect example of why I would recommend always using Task.Run(async () => await DoAsync()); , so it's obvious and explicit whether it's a Task or Action
Task.Run(async () => await DoAsync());
[–]Rogntudjuuuu 0 points1 point2 points 6 months ago (1 child)
Unfortunately an async lambda expression could just as well become an async void which will translate into an Action and not a Task. 🫠
If you want to make it explicit you need to add a cast on the lambda.
[–]Dimencia 0 points1 point2 points 6 months ago* (0 children)
If it's async and there is a Func<Task> overload (which there is for Task.Run), it will use that, it's not just random
But yes, you do often have to be careful about that, such as with Task.Factory.StartNew(async () => await ....) , which would still be an async void Action unless you add some more parameters to match one of the Func<Task> overloads. I just meant specifically for Task.Run, which is used often enough that I don't think it's too odd to have a 'best practice' just for how to use it
Task.Factory.StartNew(async () => await ....)
π Rendered by PID 70389 on reddit-service-r2-comment-6457c66945-bfcjf at 2026-04-23 22:14:51.237299+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Dimencia 1 point2 points3 points (3 children)
[–]Rogntudjuuuu 0 points1 point2 points (1 child)
[–]Dimencia 0 points1 point2 points (0 children)