Global Variable

  • Thread starter Thread starter sendhil
  • Start date Start date
S

sendhil

hi,
I have a global variable(integer) in my webservice. Iam incrementing
it every time the webservice is called. There may be more than one
call to the webservice at the sametime.

I want increment the integer in a synchronized way. How can i do
this.

Thanks
sendhil
 
sendhil said:
hi,
I have a global variable(integer) in my webservice. Iam incrementing
it every time the webservice is called. There may be more than one
call to the webservice at the sametime.

I want increment the integer in a synchronized way. How can i do
this.

Thanks
sendhil

For this situation, the simplest way for synchronizing the access of the
variable is using System.Threading.Interlocked class, I think. Use the
method, Increment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top