We help IT Professionals succeed at work.
Get Started

Timer instead of sleep vb.net

934 Views
Last Modified: 2012-06-21
I am trying to have a program wait before execution however Threading.sleep does not allow execution while it's waiting.  

I'm trying to set up a timer to pause execution but I'm unsure how to do it.

Thanks,
JOe K.
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, _
                        ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) _
                        Handles WebBrowser1.DocumentCompleted

        'MsgBox(cnt)
        Dim t As Timer
        t.Start() 'how can I use this to delay the subsequent 
'lines of code.  Lets say I want a 3 second delay to allow
'a page to fully load (including javascript which the event
'is not waiting for).
        Dim MSDNpage As String = WebBrowser1.Document.Body.InnerText
        My.Computer.FileSystem.WriteAllText("C:\Quib\" & cnt & ".txt", MSDNpage, False)
        nextPage()
    End Sub

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This problem has been solved!
Unlock 3 Answers and 10 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE