I wrote a WCF service, but the data stored in the service implementation does not occur between calls, even here What can I do with a static variable that is not stored?
The service implementation is as follows:
public class storage: ISO, secure {secure static item} _data; #region IStorage members enter public Zero (object [] data) {lock (_data) {_data = _data.Concat (data) .toArray (); }} Select public object []Never () {lock (_data) {return (object []) _data. Clone (); Service Host is a console application: Fixed zero main (string [] args) {ServiceHost serviceHost = New service host (TypeSpeedStorage); ServiceHost.Open (); Console.lightline ("service is running, please enter 'to exit ...'); Console.ReadLine ();}
By default, the WCF instanceMode is set to per call, which means the data used in the service is specific to that client call.
On service
[ServiceBehavior (InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)] Try adding to the public class MyService: IService
Service a singleton .
No comments:
Post a Comment