jorge Posted April 21, 2004 Posted April 21, 2004 Hi, i'm at a point where i need to wait 5 seconds befor contineuing, how do i do that? :confused: Quote Jorge - http://www.blackdot.be/?page=apache.htm
Administrators PlausiblyDamp Posted April 21, 2004 Administrators Posted April 21, 2004 System.Threading.Thread.Sleep(5000) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
jorge Posted April 21, 2004 Author Posted April 21, 2004 System.Threading.Thread.Sleep(5000) thanx, i'll try that Quote Jorge - http://www.blackdot.be/?page=apache.htm
Joe Mamma Posted April 21, 2004 Posted April 21, 2004 Hi, i'm at a point where i need to wait 5 seconds befor contineuing, how do i do that? :confused: the question is. . . why do you need to wait 5 seconds? are you waiting for some process to finish??? having a process wait a specific period of time to continue is poor practice. it leads to platform dependencies. I am guessing you are looking to perform asynchonous processing. . . look into Asynchronous Programming Overview in the help file!!! It will make you a better programmer! Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
JABE Posted April 22, 2004 Posted April 22, 2004 having a process wait a specific period of time to continue is poor practice. it leads to platform dependencies. I can't see how. Perhaps you can elaborate for the benefit of those who do not know (like me). Thanks. Quote
Denaes Posted April 22, 2004 Posted April 22, 2004 If you're waiting for something slower than your program, which is normally harware related, use Application.DoEvents(). It stops the program, makes sure everything is caught up, then continues. I remember having to use this when I was doing a LOT of reading/writing in collections from/to files (scanning 5,000 text documents for specific text, then grabbing the next word). You also need to do this when displaying your graphics in a game loop. If it gets too complex. Quote
*Experts* Nerseus Posted April 22, 2004 *Experts* Posted April 22, 2004 I think the question is (again): Why do you want to wait 5 seconds? A solution can't be offered if we don't know the problem. If you just want to wait 5 seconds to see who, then Sleep will work perfectly. If you're working around some issue, we'll need to know what it is to help. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
jorge Posted April 22, 2004 Author Posted April 22, 2004 i have a program i run, and i read the output, it stays open if i don't close it with: Apache_Proc.CloseMainWindow() but if i do it to soon, i cant read the output. Private Sub ap_test() With Args .FileName = sApache_dir & "\bin\apache.exe" .Arguments = "-t -n """ & sApache_service & """ " .UseShellExecute = False .RedirectStandardError = True .RedirectStandardOutput = True .WindowStyle = ProcessWindowStyle.Hidden End With Apache_Proc = Process.Start(Args) System.Threading.Thread.Sleep(5000) Try Apache_Proc.CloseMainWindow() Catch ex As Exception 'do nothing End Try Dim sData As String = Apache_Proc.StandardError.ReadLine If sData = "Syntax OK" Then txtStatus.Text = txtStatus.Text & vbCrLf & "[" & GetTime() & "] " & "Apache Test result: Syntax OK" If Me.Visible = False Then SysTray.ShowBalloon(NotifyIcon2.NotifyIcon2.EBalloonIcon.Info, "Apache Test result: Syntax OK", "ApacheMon", 5) End If Else txtStatus.Text = txtStatus.Text & vbCrLf & "[" & Date.Now.Hour & ":" & Date.Now.Minute & ":" & Date.Now.Second & "] " & "Apache Test result: Error found, please check your config" If Me.Visible = False Then SysTray.ShowBalloon(NotifyIcon2.NotifyIcon2.EBalloonIcon.Info, "Apache Test result: Error found, please check your config", "ApacheMon", 5) End If End If End Sub this is what i have now, and yes on a slow computer 5 sec maybe to litle, but i see no other way(if you do, feel free to comment) Quote Jorge - http://www.blackdot.be/?page=apache.htm
Joe Mamma Posted April 22, 2004 Posted April 22, 2004 Apache_Proc = Process.Start(Args) System.Threading.Thread.Sleep(5000) wouldnt this work? Apache_Proc = Process.Start(Args) while not Apache_Proc.HasExited do Application.DoEvents() this is what i have now, and yes on a slow computer 5 sec maybe to litle, but i see no other way(if you do, feel free to comment) JABE. . are you paying attention? Perhaps Platform Dependency is the wrong term as opposed to Hardware Dependency. . . Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
jorge Posted April 22, 2004 Author Posted April 22, 2004 Apache_Proc = Process.Start(Args) while not Apache_Proc.HasExited do Application.DoEvents() No, sins it doesnt close by itself Quote Jorge - http://www.blackdot.be/?page=apache.htm
Arch4ngel Posted April 22, 2004 Posted April 22, 2004 No' date=' sins it doesnt close by itself[/quote'] Apache_Proc = Process.Start(Args) while not Apache_Proc.HasExited do Application.DoEvents() Here is how I see it. Start a thread and in the thread... while not Apache_Proc.HasExited or something like this... (while your output is not ready) Application.DoEvents And outside the While... do the action needed for your outpout. -Stay-ZeN- Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
jorge Posted April 22, 2004 Author Posted April 22, 2004 I stumble ont the awnser by acident when i do: Apache_Proc.Refresh() after i start the procces it exit's normaly. so i don't need tp wait Quote Jorge - http://www.blackdot.be/?page=apache.htm
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.