-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NRE on Dispose in ExecutionTimer #779
Comments
Hmm, unless someone messes with the SynchronizationContext, the continuation "should" happen on the thread that started the await. |
Hmm ok I see. I'll try to write a unit test that reproduces the issue and figure out more precisely what's going on. Maybe it's a platform issue, I'll see if it behaves the same way on Windows. EDIT: For what it's worth I'm getting different threads before and after the |
The intent of the However it sounds like I haven't accounted for managing |
Yeah unless we're timing a lot of things at the same time the pool might end up creating fewer stopwatches than the Thanks for the information, I'll work on something to deal with the issue. |
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.It's happening here and in other similar blocks of code
Basically the
ThreadStatic
t_stopwatch
field is assigned inside theLogger.LogExecutionTime
call, but when we come back from the 'await' the code is/can be executed on another thread andLogger.LogExecutionTime
is eithernull
, the rightt_stopwatch
or one from another thread.So before I submit a PR making
t_stopwatch
an instance field I wanted to ask why is itThreadStatic
? 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)
The text was updated successfully, but these errors were encountered: