arno.huetter
8/22/2003 8:08:00 PM
A static variable might work, but I would very much recommend to store
it in the webservice's HttpApplicationState (WebService.Application)
instead. This allows you to share global information across multiple
sessions and requests.
Regards,
Arno Huetter
Thijs Sloesen <epidemi@seekitfast.com> wrote in message news:<Xns93DF802722B85Epidemi@62.45.45.76>...
> Hi,
>
> I'm wondering what the scope is of a C++ .NET web service.
>
> For instance, the following code adds 1 to the value of 'i' and sends this
> value to the client each time it is called:
>
> String __gc* MyWebserviceClass::HelloWorld()
> {
> static int i = 0;
> ++i;
> return i.ToString();
> }
>
> This - and the fact that a web service has a member variable Application
> (of type HttpApplicationState) - implies that the web service is not
> released when it has been called, but remains running in the web server.
>
> Is this guaranteed in .NET, or is this just a coïncidence and will the web
> service be released if it isn't called frequently and resources get low?
>
> I am writing a web service that often receives data from its clients. This
> data needs to be saved for future use because clients might request data
> that other clients posted. For performance issues, I'd like to keep as much
> data in memory as possible (perhaps on a "most frequently used" basis),
> rather than writing everything to a database. But for this to work, I need
> to know if it's safe to just keep data in memory and only write it to a
> database in the Application_End() function in global.asax.h.
>
> Thanks,
>
> Thijs Sloesen