joecool2005 Posted September 20, 2007 Share Posted September 20, 2007 HiOn the following code Dim i As Integer For i = 0 To 10 Thread.Sleep(1000) Response.Write("test") Session("State") = i + 1 Next Session("State") = 100 I want to write "test" every 1000 miliseconds but I'm not able.Please help!ThxJoe Link to comment Share on other sites More sharing options...
jesh Posted September 21, 2007 Share Posted September 21, 2007 If this is for a web application (ASP.NET), then you're not going to be able to because of the way HTTP works. That code you presented would cause the Response to take 10 seconds and then immediately present "testtesttesttesttesttesttesttesttesttest" to the browser's screen.To make this function, you'll have to use javascript on the client side. <div id="test"></div><script>var i = 0;function writeTest(){ document.getElementById("test").innerHTML += "test"; i++; if(i < 10) { setTimeout("writeTest();", 1000); } }writeTest();</script> Link to comment Share on other sites More sharing options...
Nim199 Posted November 11, 2007 Share Posted November 11, 2007 In VB, the code is: System.Threading.Thread.Sleep(1000) Link to comment Share on other sites More sharing options...
aspnetguy Posted November 12, 2007 Share Posted November 12, 2007 In VB, the code is: System.Threading.Thread.Sleep(1000)What he had is also correct if he indluded the system.Threading namespace.You could do this but using javascript and setTimeout would probably be more efficient. Dim i As Integer For i = 0 To 10 Thread.Sleep(1000) Response.Write("test") Response.Flush() Session("State") = i + 1 Next Session("State") = 100 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.