c# - Topshelf windows service, Structure map - > achieve per request object lifecycle for timer elapsed event -


i have windows service application hosted topshelf. initializing structure map container once, when service started. have timer, scheduled tasks triggered on each timer elapsed event. have "per request " object creation have same instances of initialized objects durring 1 timer tick, , dispose them when job finished. on next tick of timer have new object instances (e.g. objects dbcontext ef.. ). how can achieve structure map possible?

i think you're looking nested container:

http://structuremap.github.io/the-container/nested-containers/

the naive implementation pass application's container elapsed event handler, call getnestedcontainer() on it, , dispose of nested container before handler exits.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -