I need that in order to execute this but i think the question is more general - how does one get an
I think you are badly misunderstanding the purpose of the
OnRun method. As the linked documentation states:
The system calls this method when the associated background task has been triggered.
It is a
protected method that is provided as part of the infrastructure. As such, it is called automatically by infrastructure code, and you (the client) are only supposed to override it for handling purposes.
You basically never call
OnRun yourself, thus you never need to provide any of its parameters. Rather, you are passed a reference to an object that implements
IBackgroundTaskInstance when the function gets called, which you can use in your implementation of the method's body in a derived class.