[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

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
1 Answer

Thijs Sloesen

8/22/2003 9:26:00 PM

0

Hi,

thanks for your reply. I'm indeed storing my data in the webservice's
HttpApplicationState member variable. I just wanted to make sure that the
web service would not be completely shut down after one request, hence my
example with the static variable.

Thanks again.

Regards,

Thijs Sloesen

arno.huetter@aon.at (Arno Huetter) wrote in
news:afd36318.0308221207.17e77b5d@posting.google.com:

> 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
>