Description
I'm breakpointing through the PSES to figure out how the Find References mechanism works for another issue and I'm getting NRE in ExecutionTimer
quite frequently.
The NRE happens on the first line of the Dispose()
method.
t_stopwatch.Stop();
It's happening here and in other similar blocks of code
using (Logger.LogExecutionTime($"Script analysis of {scriptFile.FilePath} completed."))
{
semanticMarkers = await editorSession.AnalysisService.GetSemanticMarkersAsync(scriptFile);
}
Basically the ThreadStatic
t_stopwatch
field is assigned inside the Logger.LogExecutionTime
call, but when we come back from the 'await' the code is/can be executed on another thread and Logger.LogExecutionTime
is either null
, the right t_stopwatch
or one from another thread.
So before I submit a PR making t_stopwatch
an instance field I wanted to ask why is it ThreadStatic
? Am I going to break everything in a way I'm not seeing right now?
Thanks
(I'm running the application on Arch Linux, building with VS Code)