C# Interview

Async/Await, Tasks & Multithreading

C# interview questions covering async/await, tasks & multithreading.

10 Questions Filter by level

Interview questions

Open a question for the full answer, code and interview guidance.

10 Results
61
Mid-LevelIntermediate

What is asynchronous programming in C#?

Asynchronous programming allows a thread to avoid blocking while waiting for an operation such as database access, HTTP communication, file I/O, or another asynchronous resource.

62
Mid-LevelIntermediate

What are async and await in C#?

The async modifier allows a method to use await and normally indicates that the method returns Task, Task<T>, ValueTask, or ValueTask<T>. The await operator asynchronously waits for an awaitable operation to complete.

63
Mid-LevelIntermediate

What is Task and Task<T> in C#?

Task represents an asynchronous operation that does not produce a result value. Task<T> represents an asynchronous operation that eventually produces a value of type T.

64
Mid-LevelIntermediate

What is the difference between synchronous and asynchronous programming?

Synchronous code normally waits for each operation to complete before continuing. If a thread performs blocking I/O, that thread remains occupied while waiting.

65
Mid-LevelIntermediate

What is the difference between Task.WhenAll and Task.WhenAny?

Task.WhenAll returns a task that completes when all supplied tasks have completed. It is useful when independent asynchronous operations can run concurrently and all results are required.

66
Mid-LevelIntermediate

What is a thread in C#?

A thread is an execution path within a process. Multiple threads can execute work concurrently.

67
Mid-LevelIntermediate

What is the difference between a process and a thread?

A process is an operating-system container for a running application. It has its own virtual address space and resources.

68
Mid-LevelIntermediate

What is a race condition, and how can it be prevented?

A race condition occurs when multiple execution paths access shared mutable state concurrently and the program's result depends on timing or execution order.

69
Mid-LevelIntermediate

What is the lock keyword in C#?

The lock statement provides mutual exclusion around a critical section. Only one thread can execute code protected by the same lock object at a time.

70
Mid-LevelIntermediate

What is CancellationToken in C#?

CancellationToken provides a cooperative mechanism for requesting cancellation of asynchronous or long-running operations.