- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
using
awaitinstead of justTask.Runin the main function would make it run one task and then the other. the right way to do this in parallel is something likeTask.WaitAll(ProcessLogQueue(), ProcessFilesInFolder());Admin
except neither of those functions are async. they used Task.Run instead of just spawning actual threads
Edit Admin
No. We try to load the file. (If we failed, we clearly didn't try and load, because we didn't load.)
Or "test" or "tEsT" (etc.) because it's a case insensitive comparison (the "true" at the end ends up in a parameter called "ignoreCase"(1)...). And it's not "appears in", but "is exactly" (subject to the vagaries of what "exactly" means for a case-insensitive comparison).
(1) See e.g. https://learn.microsoft.com/en-us/dotnet/api/system.string.compare?view=net-10.0#system-string-compare(system-string-system-string-system-boolean)
Edit Admin
I wish all my customers were that smart.
Edit Admin
I see that you & I have matching pet peeves.
Admin
Missed a perfect chance to annoy other pendants with slightly different pet peeves by saying "me and you"
Edit Admin
I thought of that but couldn't bring myself to do it. James Dean, I am not.
Edit Admin
Mixing traditional threading (Thread.Sleep) with parallel executions (Task) which enqueue via a safe execution and synchronization context into a thread pool is a super bad idea. Especially with stuff like Sleep or Abort you can literally can deadlock or block other tasks, so this code is pretty much a time bomb if it hasn't happened multiple times already.
Addendum 2026-01-26 09:01: Personally I don't understand what is so hard about this.
It's pretty easy, as long as you know the basics of what you are doing.
Edit Admin
You can pass
Taskobjects to theWaitAll.