我的任务是支持旧的VB6应用程序.(对我来说)我遇到ADO连接超时属性问题.如果服务器存在,下面的方法可以正常工作,但如果服务器不存在或网络连接没有启动,即使intTimeout设置为1,也需要整整30秒才能超时.
有没有办法让ADO更快地无法连接?这甚至可能吗?谢谢!
Public Sub GetConnectionObject(ByRef oCn As ADODB.Connection, strServer As String, strInitialCatalog As String, Optional intTimeout = 10)
Dim strConnectionString As String
strConnectionString = "Data Source=[SERVER];Provider=SQLOLEDB.1;User ID=ScanReq1;Password=ScanR3Q;Initial Catalog=[INITIALCATALOG];ConnectionTimeout=" & intTimeout & ";"
strConnectionString = Replace(strConnectionString, "[SERVER]", strServer)
strConnectionString = Replace(strConnectionString, "[INITIALCATALOG]", strInitialCatalog)
Set oCn = New ADODB.Connection
oCn.CursorLocation = adUseClient
oCn.ConnectionString = strConnectionString
oCn.CommandTimeout = intTimeout
oCn.ConnectionTimeout = intTimeout
oCn.Open
End Sub
Run Code Online (Sandbox Code Playgroud) 我注意到,当我尝试阅读更多信息然后被发送到我的服务器时,Web浏览器将冻结.我看到我的套接字冻结,因为网络浏览器返回的信息较少,然后它正在尝试阅读.有没有办法在Currtly上设置一个时间我正在使用输入流
public String ReadLine()
{
String out;
out="";
// read in one line
try{
request = new StringBuffer(1000);
boolean f=true;
while(true)
{
int c=in.read();
if (c=='\r')
{
// next should be a \n
// Program freezed hear
c=in.read();
if (f==true)
return "";
break;
}
f=false;
out=out+(char)c;
request.append((char)c);
} // end while
} catch(IOException ec)
{
System.out.println(ec.getMessage());
}
System.out.println(request);
return out;
}
Run Code Online (Sandbox Code Playgroud) 我在加载屏幕上有一些代码,在用户登录前等待五秒钟:
setTimeout(
function() {
$.doPost("http://mysite.com", {
username: results.rows.item(0).username,
password: results.rows.item(0).password
});
}, 5000);
Run Code Online (Sandbox Code Playgroud)
在页面等待的同时,屏幕上还有一个"退出"按钮,如果点击,则需要发布此帖子.基本上,用户在自动登录之前有五秒钟点击注销.注销按钮有一个onClick,无论我放在该功能中,它继续登录,我怎么能让那个按钮停止$.doPost发生?
我想让一个元素淡入,并在它消失之前在页面上停留7秒.我可以随时取消它.我定义了以下功能.但是当我打电话时info_timeout.setup(ele, 'some msg here'),电子元件刚刚消失并立即消失.
我错过了什么吗?
var info_timeout = {
show_info: function(){
this.ele.html(this.msg).fadeIn('normal');
this.id = setTimeout(this.hide_info(), 7000);
},
hide_info: function(){
console.log(this.ele, this.id);
this.ele.fadeOut('slow');
delete this.id;
},
setup: function(ele, msg) {
this.ele = ele;
this.msg = msg;
this.cancel();
this.show_info();
},
cancel: function() {
if(typeof this.timeoutID == "number") {
clearTimeout(this.id);
delete this.id;
}
}
Run Code Online (Sandbox Code Playgroud)
};
谢谢.
我试图将延迟添加到一个简单的下拉菜单中。使用以下代码,我得到了延迟,但种类错误。当我非常快地将鼠标移到菜单上时,它会延迟它,但在300ms之后仍会打开它。正确的做法是,当鼠标悬停在菜单上300ms时(与离开菜单时一样)打开菜单。
$('#menu-item-1226:not(.parent-pageid-1225 #menu-item-1226)').hover(function(){
var menu = this;
setTimeout(function(){
$(menu).find('ul').slideToggle(100);
}, 300);
});
Run Code Online (Sandbox Code Playgroud)
我是否必须以stop某种方式做到这一点?或者什么是正确的方法?
提前致谢
如果所有都具有默认值,是否可以在Python中设置函数调用中的几个参数?
示例:在ftplib.FTP模块中定义:
ftplib.FTP([host[, user[, passwd[, acct[, timeout]]]]])
Run Code Online (Sandbox Code Playgroud)
所有这些参数都有一个默认值,因此您不需要全部设置它们,例如,您可以调用ftp = ftplib.FTP()以获取FTP对象.但是,如果我只想设置timeout参数怎么办?我怎么做到这一点?
function animateGraph() {
var graph;
for(i=0; i<10; i++)
{
var start = new Date();
while((new Date()) - start <= 500) {/*wait*/}
document.getElementById("timeMark").innerHTML = phoneX[i].epoch;
}
}
Run Code Online (Sandbox Code Playgroud)
循环工作.等待有效.但是document.getElement直到数组中的最后一项才出现...为什么?
在我的Web.config文件中,我一直在尝试设置会话超时.我使用了以下代码:
<configuration>
<system.web>
<sessionState timeout="1"></sessionState>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,超时仍设置为默认的20分钟.试图找出设置不适用的原因.请帮忙!谢谢!
下面的简单方法是抛出超时错误,我无法弄清楚为什么会这样.这可以连续多次执行,我想知道这可能是原因吗?
public static Boolean UpdateMessageState(int messageId, int stateId, string message)
{
var repo = new MailItemRepository();
try
{
var objTask = repo.GetMailByMailId(messageId);
objTask.State = stateId;
objTask.Result = message;
repo.Save();
return true;
}
catch (Exception ex)
{
logger.Info(ex.Message);
logger.Info(ex.InnerException);
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
错误跟踪:
2012-07-02 15:26:38.1002|INFO|EF.Methods.MailMethods.UpdateMessageState|System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand …Run Code Online (Sandbox Code Playgroud) c# linq-to-entities entity-framework timeout exception-handling
如果用户不更改页面10分钟,我会使用此代码记录用户.
$inactive = 600;
if(isset($_SESSION['timeout']) ) {
$session_life = time() - $_SESSION['timeout'];
if($session_life > $inactive) {
header("Location: logout.php");
}
}
$_SESSION['timeout'] = time();
Run Code Online (Sandbox Code Playgroud)
你可以看到它很简单.我在所有受保护页面的顶部包含此功能,如果脚本未运行10分钟,则下次刷新页面时,用户将被发送到我的注销脚本.
不过那就是问题所在.在$ session_life> $ inactive变为true之后,需要再次运行脚本以便用户注销.一旦成为现实,我需要立即退出该人.
如果事情变得太复杂,有没有办法做到这一点?(即不使用AJAX)
timeout ×10
javascript ×3
jquery ×2
session ×2
ado ×1
asp.net-mvc ×1
c# ×1
clear ×1
delay ×1
dom ×1
ftp ×1
inputstream ×1
java ×1
logout ×1
loops ×1
php ×1
python ×1
settimeout ×1
sql ×1
tcp ×1
vb6 ×1
web-config ×1