开发者

What is synchronization in asp.net exactly?

Hello how to synchronize asp.net page . means how can we maintain synchr开发者_如何学Conization in asp.net while loading pages/ page ?


if you mean :

lock(someVariable)
{
    ///Some code
    //Some read operations
    //Some write operations

}

This is to ensure that two threads accessing the code inside the braces, can only access the code one at a time.

Since the code contains read and write operations, if two threads were accessing the code at the same time, you could get inconsistent states for your data (just as an example). Thus, without the lock, the above code would not have been "Thead safe".

There are many such cases where thread safety might be required and the lock keyword addresses these cases.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜