Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ATL 3.0 Services & SINGLETONS

Status
Not open for further replies.

mattKnight

Programmer
May 10, 2002
6,230
GB
Hi all

I have a service written using ATL3.0 (wizard written code mostly ;-)). I have modified the eventlog code to use message dlls etc.

I have added a simple ATL object to this code and added the following to that declaration:
DECLARE_CLASSFACTORY_SINGLETON(CStates)
CStates has interface IStates
and dispinterface _IStatesEvents

All appears ok, apart from the closing entry in eventlog.
it appears that the CServiceModule destructor fires (before the call to the eventlog routine. As the destructor deletes the pointer to the event logging class, i would expect all hell to break loose( exceptions everywehere) But it all goes silent (and happy). Currently the code is STA so it shouldn't be a threading problem.

However, the more major issue is:
I have written a VB app to mointor and draw information from the CStates class (instantiated by the service).

so
private withevents obj as servicelib.CStates

form load
set obj = new servicelib.cstates

etc

Why do I get 2 instances of CStates? They are both visible in taskmanager with different PIDS. Using traceing code in the CStates constructor shows two entries and exits!
I thought that was the point of SINGLETONS, that you get one instance however many calls to (implied/explicit) to CreateInstance!


All help greatfull appreciated

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top