Primary constructor parameter is null after being run in a Task
The following snippet of code is responsible for starting a background service
This service is being registered with Microsoft DI as a singleton.
When the
StartExecuting
function is called, the callService
is correctly being passed.
However if I set a breakpoint inside the lambda of Task.Run, callService
is null there...
Any ideas?6 Replies
Small Update: it isn't null, the debugger is messing something up :/
Also in before you tell me about BackgroundServices: I'm in blazor hybrid where these type of stuff dont work.
There will be no a backing field for
callService
if it is not used in your class. Where is it used?
is translated to
Complete case:
It's used inside
DoWork
It works as intended, it's just the debugger is showing weird information about the variables
You can take a look at this small snippet:
It's a recreation of the debugger bug
If you debug inside the lambda or DoWork
the printService would be shown as null (although it isn't)The generated state machines are confusing. 🙂
What do you mean
I attempted to understand the flow but the generated state machines by
sharplab.io
are confusing.