returning to calle from a critical region

  • Thread starter Thread starter deostroll
  • Start date Start date
D

deostroll

There is a remote method that returns a datatable to the client. I a
talking of a scenario when there are multiple requests which invoke
the same method. I have a synchronized region of code. By that I mean
only one thread/request should execute that code; others should wait.
I've written simply with a lock. My doubt is that I am doing a return
within that region. Will this release the lock on the synchronized
region?

lock(Handle)
{
//some fetching logic here

//returning datatable
return myDataTableObj;
}


--deostroll
 
Definetely, it will release the lock.

Lock is defined as try { } finally { } block, so, the lock is always
released in finally section.

Cheers,
pennanth
 
Back
Top