一次仅一个用户 [英] Only one user at a time
本文介绍了一次仅一个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不记得它的语法,例如Begin Transaction
和End Transaction
或lock
和unlock
.它仅允许一个 user 线程进入代码块.谁能帮我记住它.
在此先感谢!
I can''t remember the syntax it''s like Begin Transaction
and End Transaction
or lock
and unlock
. It only allows one user thread to enter the code block. Can anyone help me remembering it.
Thanks in advance!
推荐答案
对于ASP.Net?我不相信有可能编写一个单用户网站.
For ASP.Net? I don''t believe it is possible to write a single-user web site.
您可以使用lock
语法提供线程同步
http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx [ ^ ]
这与线程有关,而不是与用户"操作有关.
对于您对Gregory.Gadow的回答的评论,如果您希望ID是唯一的,则一定要将该ID留给基础数据库操作(Identity字段)进行分配.
You can use thelock
syntax to provide thread syncronisation
http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx[^]
That''s to do with threading, rather than ''user'' actions though.
For your comment on Gregory.Gadow''s answer, if you wanted an ID to be unique you''d certainly leave that to an underlying database operation (an Identity field) to allocate.
您是否在谈论.net框架提供的lock
关键字.
例如
Are you talking aboutlock
keyword which .net framework provide.
e.g.
object objLock = new object();
lock(objLock)
{
//Do the required stuff here.
}
这篇关于一次仅一个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文