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.
 
Back
Top