Code Room
Code reviewHardcr-g586
Subject Concurrency await holding lockLevel Senior–Staff~31 minCommon in Concurrency interviewsIndustries Software development, Technology

Question

Review this C# cache that serializes refreshes with a lock.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewcsharp
private readonly object _gate = new object();private Data _data; public async Task<Data> GetAsync() {    lock (_gate) {        if (_data != null) return _data;        _data = await FetchFromNetworkAsync(); // refresh        return _data;    }}
Run or narrate your approach, then ask the coach.