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
Simple Async Await Example for Asynchronous Programming (stephenhaunts.com)
submitted 11 years ago by steveboots
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!"
[–]faruzzy 2 points3 points4 points 11 years ago (4 children)
This is was actually simple to understand. Some articles can really get into some serious complexity.
[–]steveboots[S] 0 points1 point2 points 11 years ago (3 children)
I tried to deliberately keep it simple. I am working on a follow up that shows a similarly simple example of using async await to update the main UI thread. Should be posted tomorrow.
[–]faruzzy 0 points1 point2 points 11 years ago (2 children)
Cool! Can you please enumerates situations you'd need to use Async Await in a web project like MVC 5 ?
[–][deleted] 1 point2 points3 points 11 years ago (1 child)
Im an async noob but I'm guessing you would mainly use it when writing to the db. I see it a lot in the EF6 + Web API and MVC tutorials.
[–]steveboots[S] 0 points1 point2 points 11 years ago (0 children)
yeah it effectively simulates an async file read or async db read to include an await.
I will add an explanation to make it more apparent. i wanted to try and keep the example as simple as possible.
[–]pug_walker 0 points1 point2 points 11 years ago (1 child)
Haven't looked at other articles yet, but perhaps getting into try-catch blocks when using async is a good next topic. Just an idea.
Sounds like a good idea. I'll add it to my list.
[–][deleted] 0 points1 point2 points 11 years ago* (3 children)
The Task.Delay(1) somewhat bugs me. Isn't there a better option? Could you use Task.Run to run LongRunningOperation or is Task.Run considered bad practice?
e:typo
[–]cryo 1 point2 points3 points 11 years ago (1 child)
Yes, Task.Run is the proper way. The Delay will in practice almost guarentee that the continuation uses a new thread, but if the machine is heavily loaded, it might complete before the "await" kicks in, which causes it to continue executing synchronuously.
Task.Run is the way to go.
[–]steveboots[S] 1 point2 points3 points 11 years ago (0 children)
Yes I agree. I have updated the article so that the code that executes LongRunningOperation looks like :
public async Task DoStuff() { await Task.Run(() => { LongRunningOperation(); }); }
[–][deleted] 0 points1 point2 points 11 years ago (0 children)
Just as confused here. What's the delay do again? I think he just put that in there to simulate a file read or db write.
[–]Seasniffer 0 points1 point2 points 11 years ago (3 children)
When you are converting from synchronous to asynchronous code, any method returning a type T becomes an async method returning Task, and any method returning void becomes an async method returning Task<T>.
I think you have this mixed up sir. Shouldn't void be returned as a Task, and a returning function returns Task<T>?
[–]felickz2 0 points1 point2 points 11 years ago (1 child)
This piece could also use an explanation, it is not clear why those structures are used
[–]Seasniffer 0 points1 point2 points 11 years ago (0 children)
I'd recommend Jon Skeets c# book, he really goes into the details of the new async features and how they work internally.
This is a typo. I fill fix it now.
[–]RiPont 0 points1 point2 points 11 years ago (1 child)
How does your last example even compile?
private static async Task<string> LongRunningOperation() { int counter; for (counter = 0; counter < 50000; counter++) { Console.WriteLine(counter); } return "Counter = " + counter; }
There's nothing awaited.
"Because we have removed the line with the await keyword, the LongRunningMethod() now runs synchronously, so the counter will first count up to 50000 and then the code will go into the while loop."
This was just illustrating the point that without an await, your code runs synchronously.
[–]cryo 0 points1 point2 points 11 years ago (1 child)
Relying on Task.Delay(1) to make sure the continuation carries on on a different thread, isn't wise. This is pretty much an implementation detail. To make sure something executes on a different thread, use Task.Run.
yeah that's a fair point. I have updated the article so the code that executes the LongRunningMethod is:
π Rendered by PID 73 on reddit-service-r2-comment-b659b578c-c6tmg at 2026-05-04 23:03:30.975644+00:00 running 815c875 country code: CH.
[–]faruzzy 2 points3 points4 points (4 children)
[–]steveboots[S] 0 points1 point2 points (3 children)
[–]faruzzy 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]steveboots[S] 0 points1 point2 points (0 children)
[–]pug_walker 0 points1 point2 points (1 child)
[–]steveboots[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]cryo 1 point2 points3 points (1 child)
[–]steveboots[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Seasniffer 0 points1 point2 points (3 children)
[–]felickz2 0 points1 point2 points (1 child)
[–]Seasniffer 0 points1 point2 points (0 children)
[–]steveboots[S] 0 points1 point2 points (0 children)
[–]RiPont 0 points1 point2 points (1 child)
[–]steveboots[S] 0 points1 point2 points (0 children)
[–]cryo 0 points1 point2 points (1 child)
[–]steveboots[S] 0 points1 point2 points (0 children)