12
donkulator
125d

await Task.Run(() => { age++; });

Comments
  • 10
    that's a very bad example of using task.run. the operation inside takes significantly less time than the task-scheduling overhead.

    if anything, you should use `Interlocked.Increment(age)` to make it 100% thread safe.
  • 5
    Also, happy birthday
  • 5
    @tosensei Hmm. Based on that, I might have to approach this from a completely different angle:

    using var age = serviceContainer.GetService<IAge>();

    using var rpot = serviceContainer.GetService<IRelentlessPassageOfTime>();

    rpot.Advance(age);
  • 4
    @donkulator or as alterative:

    Environment.DisableBotheringAboutCompletelyMeaninglessSocialConventions();
  • 2
    Happy Birthday to you

    God bless you!
  • 3
    Joyous anniversary, good sir!
  • 0
    What does donkulator mean?
  • 1
    queueMicrotask(() => globalThis.age++);

    This is a safe way, it executes after all pending tasks have been executed.
  • 0
    Happy birthday.
Add Comment