ENGLISH 意见建议 网站地图 网站帮助
广泛智力汇聚   高效成果传播   先进机制培育
联盟首页  |  协同开发  |  开放源码库  |  安全告警  |  开源导航  |  文档中心  |  服务支持  |  共创论坛  |  关于联盟


注册会员 网站帮助
    您的位置 »
    今天是: 2010年11月22日    
项目搜索

完全匹配   
开源软件
软件分类表
新发布软件
其它网站镜像
代码片断
协同开发
文档
论坛
寻求协助
热点项目
站点状态
编译工厂

联系我们
关于联盟

代码片段库:
查看代码片段

浏览 | 提交新的代码片段 | 创建代码包

Toggling Checkboxes

类型:
Function
类别:
Other
许可证:
GNU General Public License
语言:
Visual Basic
 
描述:
This is mutex problem, arising in huge websites, where a lot of information for each session user has to be unique. IHere the solution of mutex problem using web technology ASP. The same logic can be implemented in others technology also. Or even this can be implemented in client server application. For any bugs or enquiry please give me a mail at [email protected]. All the best.

该代码片段的版本系列:

片段ID 下载版本 提交时间 提交人 删除
48371.02003-12-17 23:15cbd001

点击"下载版本"来下载该代码片段.


最新版本的代码片段: 1.0


'Copy Right Himadrish Laha
'You can use this code but must use this comment line
'Originally written by- Himadrish Laha <[email protected]>
'For avoid the problem in large websites when thousand of user logs-in and logs-out
'MutexSolutions In ASP

There are two files, global.asa, and index.asp. Create a directory, place there two files, then create virtualdirectory, and execute the program with 15000 user at a time. You can get 100% acuurate value.

FILE GLOBAL.ASA
---------------
<SCRIPT LANGUAGE='VBScript' RUNAT=SERVER>
'Copy Right Himadrish Laha
'You can use this code but must use this comment line
'Originally written by- Himadrish Laha <[email protected]>
'For avoid the problem in large websites when thousand of user logs-in and logs-out
'MutexSolutions In ASP
function GetNewId()
 if Application("ent") = false then	'Before enter first check
	if Application("work") = false then	'By time, if more than one user enter in this case, but only one user will be able to enter in next loop, all others have to wait
		Application("work") = true	' NOw lock the allication variables and work; You may also do ur others work here like table update or anythings
			Application.Lock
			Application("recordsid") = Application("recordsid") + 1
			Application.UnLock
			Application("work") = false	'When every things is done realeased the variable lock, and let others user in the queue can enter in this loop
			Application("ent") = false
			Session("status")=true
	else
		Application("ent") = false	'In this case one user allready working, so lets return
		Session("status") = false
	End if
else
	Session("status") = false	'No hope allready entering in first chanme, wait untill completed
end if	
End function
	
	

SUB Application_OnStart
Application("ent") = false
Application("work") = false
Application("recordsid") = 0
END SUB


SUB Session_OnStart
	Session.TimeOut = 20	' You change this variable according your need
	Session("status")=false	' By defalt status is false
	Session("ret") = GetNewId()	'First call the function and the return values is save in session variables
	while Session("status") = false	' Now in this while loops checks whether the return is tru or false, if it is false call the function untill it is true
		Session("ret") = GetNewId()
	wend
END SUB
</SCRIPT>

<SCRIPT LANGUAGE='VBScript' RUNAT=SERVER>
SUB Session_OnEnd
	
END SUB
</SCRIPT>

----------------
FILE INDEX.ASP
-----------------

<%@ Language=VBScript %>
<%
'Copy Right Himadrish Laha
'You can use this code but must use this comment line
'Originally written by- Himadrish Laha <[email protected]>
'For avoid the problem in large websites when thousand of user logs-in and logs-out
'MutexSolutions In ASP
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>

<P>燭he recorsd id is <font color="blue"><b><%=Application("recordsid")%></b></font><br><br>
For any help mail me at <a href="mailto:[email protected]">[email protected]</a>
</P>

</BODY>
</HTML>

		

提交新版本

如果您修改了一个代码片段并且觉得很应该让别人共享,您可以把这作为这个代码片段的最新版本提交上来.


联盟团体会员
合作伙伴
© 共创软件联盟 版权所有
联盟服务条款 | 联盟隐私权规则 | 联系我们
电话: (8610)68313388-5949 | 传真: (8610)88377936
京ICP备05056057号