• AzureDiamond (unregistered)

    using await instead of just Task.Run in the main function would make it run one task and then the other. the right way to do this in parallel is something like Task.WaitAll(ProcessLogQueue(), ProcessFilesInFolder());

  • L (unregistered) in reply to AzureDiamond

    except neither of those functions are async. they used Task.Run instead of just spawning actual threads

  • (nodebb)

    We first try and load a config file, and if we fail, we quit.

    No. We try to load the file. (If we failed, we clearly didn't try and load, because we didn't load.)

    Then, if the word "Test" appears in any of the CLI arguments, we run a test of some kind, and then quit

    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)

  • (nodebb)

    The customer refuses to run the service, because they ran it and it created duplicate entries. Now they don't trust it to work correctly.

    I wish all my customers were that smart.

  • (nodebb) in reply to Steve_The_Cynic

    No. We try to load the file.

    I see that you & I have matching pet peeves.

  • Jaloopa (unregistered) in reply to dpm

    I see that you & I have matching pet peeves.

    Missed a perfect chance to annoy other pendants with slightly different pet peeves by saying "me and you"

  • (nodebb) in reply to Jaloopa

    I thought of that but couldn't bring myself to do it. James Dean, I am not.

  • (nodebb)

    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.

    • If it's traditional threading, do traditional threading.
    • If it's parallel processing, do parallel processing.
    • If it's asynchronous processing, do asynchronous processing.
    • If it's traditional asynchronous processing, throw it away and write asynchronous processed code from scratch.

    It's pretty easy, as long as you know the basics of what you are doing.

  • (author) in reply to L

    You can pass Task objects to the WaitAll.

Leave a comment on “Threading the Needle in a Haystack of Files”

Log In or post as a guest

Replying to comment #690497:

« Return to Article