Andrey Selitsky
Andrey Selitsky

Reputation: 2604

Ninject kernel reference in win service

I have simple win service, that executes few tasks periodically. How should I pass Ninject kernel to all my task classes?

Is it good idea to create static variable of base task class and initialize it on service start?

Upvotes: 4

Views: 919

Answers (1)

Peter Meyer
Peter Meyer

Reputation: 26051

Rather than a static variable on the base task class, I would favor injecting the kernel into each class instance. This provides a bit more flexibility should you ever decide that you need more than one kernel (for whatever reason). The static variable in the base class just seems yucky, for lack of a better term.

Upvotes: 1

Related Questions