What is the use of Lock statement in .Net?
You can use the lock statement for handling critical situation or conditions in your code.
The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock
Example for Lock statement
lock(this)
{
for(int i = 0; i < 10; i++)
{
//Do your work
}
}
No comments:
Post a Comment