Hi everyone,
First, I want to say thanks to JWalsh for orchestrating this workshop; it has been very enjoyable and informative so far. Also, thanks to all the tutors for helping out with our questions.
Now, I have some questions regarding the uses of lock and using.
The specification states in section 1.5:
Quote:
The lock statement is used to obtain the mutual-exclusion lock for a given object, execute a statement, and then release the lock.
So, is lock just like a semaphore? Also, I am assuming that the lock is released upon exiting the block following the lock statement.
The using statement is also a little vague in my mind. The specification states this in section 1.5:
Quote:
The using statement is used to obtain a resource, execute a statement, and then dispose of that resource.
The way I translate the bold part of that quote is that the resource is immediately garbage collected upon leaving the associated block, as opposed to waiting for the garbage collector to reclaim the resource at its next convenience. If this is not the case, then what is the point of the using keyword in this context?