Services LifeCycle

Topics: Web Client Software Factory, UIP Application Block discussion, User Forum
Aug 5, 2007 at 7:17 AM
Hi All

What is the life cycle of the services? Does it live forever once the application start or it will be created once we call it?

Aug 6, 2007 at 6:39 PM
You have to add your services in WCSF programmatically by using the AddNew method to have ObjectBuilder create an instance of the service and register it in the services collection.

      // using generics:

Remember, a Services Collection can have only one instance of a service type, but you can add multiple instances of the same type to the Services collection of different composition containers.

You can read the “Compositions Container” section in WCSF’s help for further info on this:

The lifetime container keeps object references in use and prevents the objects from being garbage collected until the lifetime container is disposed.

Hope it helps!

Sebastian Iacomuzzi
Jan 16, 2008 at 12:31 AM
I'm new to WCSF.
I have a question RE: disposal of composition container. Does this happen on ApplicationEnd or SessionEnd ?
I have a problem where i have a global dataservice with a dataset cache, but when i test it on my machine i found that even after i close my browser and start
a new instance i still have my dataset with my dataloaded in memory, even before loading my dataset with my new browser instance started !

By the way i am using the MS providers for membership and roles. I created a static variable which gets to my dataservice global reference after i do the add new thing in ShellModuleInitializer.
I use this static for calling methods on my dataservice in the membership provider. Is there any alternative to inject an instance of the global service into my membership provider class rather than use a static var

I am wondering whether it is the static variable that is the cause of my dataset instance remaining in memory, or is it to do with the lifetime container not disposing my datset instance ?

Also, can i dispose an instance of the global service on session end , or is this single instance for use by all requests.
Jan 16, 2008 at 1:30 AM
Hi again,

Tidyed-up my code and emliminating my static var ref to my global service, re-test my code, but found dataset is still in memory with data loaded . I implemented a dataset.clear() in my sessionend of global.asax, but isn't there a better solution to dispose my dataset instance in WSCF ?