Both perform the same operation that is
- Singleton: “”Single Call objects service one and only one request coming in…. “
- CAO: “Client-activated objects (CAO) are server-side objects that are activated upon request from the client….”
in both cases, data is not shared, but in singleton only once client can be connected at a time, why would someone want that
Under what scenario is Singleton useful and are there any more differences in them ?
You missread the lines. Here´s the definition from the MSDN. I highlight (bold) some diffrences between those objects.
State Information is some data that you store in variables or properties of the object, to process the client request.
Since a Single call object is created when a client request it to do some work, and destroyed after it has done work, it cannot hold state information, cause each request creates a new object (It can load and store data in a datasource, to do it´s work).
A Singleton object is created only once (maybe at server starup) and lifes as long as the server process is running. It can store information in variables and properties to handle client requests, cause each client works with the same object and it isn´t destroyed after a client call.
An easy example to display the diffrence betwenn a single call and singleton object is to create a method Increment() to increment a variable (integer) in the object and write the variable to the Console. The single call object will always print the same value to the Console (1 if the variable starts with 0), while the singleton object will always print an incremented value (1, 2, 3, etc.) after each call.