【发布时间】:2012-06-29 03:52:33
【问题描述】:
我正在执行这些 webrequests 循环,我需要跟踪自第一次请求以来经过的时间(unix 时间)。例如:
Dim post1 String = "http://www.xxx.com/......" & UnixTimeNow1stCall & "......"
Dim postReq1 As HttpWebRequest = DirectCast(WebRequest.Create(post1), HttpWebRequest)
Dim post2 String = "http://www.xxx.com/......" & UnixTimeElasped1stCall& "......"
Dim postReq2 As HttpWebRequest = DirectCast(WebRequest.Create(post2), HttpWebRequest)
Dim post3 String = "http://www.xxx.com/......" & UnixTimeElasped1stCall& "......"
Dim postReq3 As HttpWebRequest = DirectCast(WebRequest.Create(post3), HttpWebRequest)
*LOOP again*
等等。换句话说,我需要在第一次调用中锁定当前的 Unix 时间,并且每当我稍后调用时(以 10 秒为间隔),我需要它来引用第一次调用。
使用它来计算当前的 Unix 时间:
公共函数 UnixNow() 只要
Dim _TimeSpan As TimeSpan = (DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)) Return CLng(_TimeSpan.TotalSeconds) End Function
每当我调用 UnixTime 时都会给我当前时间,所以结果总是 0。有什么提示吗?
【问题讨论】:
-
我建议使用
example.com作为示例域名,而不是使用其他注册的可疑内容域。 -
你是对的,乔伊。我完全忘记了这一点。从现在开始我将使用 example.com :)
标签: c# vb.net time webrequest elapsed