Skip to content
AtomicReps

Navigation

08/29Computer Science

C# Async.

How a C# program waits: tasks, awaiting, cancellation, and the failures each shape produces.

  • C# Async · 1 of 3

    Tasks

    What three ends can a task reach?

  • C# Async · 2 of 3

    Coordination

    Why can a lock body not await?

  • C# Async · 3 of 3

    Deadlocks

    A lock is held across a call that waits on other work. What does the measurement show can follow?

    typescript
    var a = new object(); var b = new object();bool tookBoth = false;lock (a){    var other = Task.Run(() => { lock (b) { return Monitor.TryEnter(a, 200); } });    tookBoth = other.Result;}Console.WriteLine($"{tookBoth} done");

Three of the 920 C# Async questions.

Keep going with C# Async, free
Next topic · 09/29C# Collections & LINQ.