1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to use 'await' instead of thread.sleep(duration)?

Discussion in 'Visual Basic .NET' started by sandrine10, Jun 8, 2014.

  1. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    621
    Likes Received:
    63
    Location:
    CyberLand
    Hi,

    coding a program to login to a website and used "threading.thread.sleep(10000)" after input the username and wanna input password after and use again "threading.thread.sleep(10000)"and signin later,but seems not working!! wanna use await but don't know how?!!

    Anybody to help.

    Thanks in advance.
     
  2. healzer

    healzer Jr. Executive VIP Jr. VIP Premium Member

    Joined:
    Jun 26, 2011
    Messages:
    2,363
    Likes Received:
    1,966
    Gender:
    Male
    Occupation:
    Marketing automation tools
    Location:
    Somewhere in Europe
    Home Page:
    Are you using it on a new thread or the main thread?
    I've never heard of "await", but there are many implementations on how to fix this.
     
    • Thanks Thanks x 1
  3. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    621
    Likes Received:
    63
    Location:
    CyberLand
    thanks healzer,if you know any alternative way to fix this please let me know.
     
  4. babypar

    babypar Jr. VIP Jr. VIP Premium Member

    Joined:
    Jan 19, 2007
    Messages:
    396
    Likes Received:
    89
    What language are you using?
    In Java you can do a thread.join() which means you will wait until another thread has finished processing before continuing, if thats any help
     
  5. sockpuppet

    sockpuppet Junior Member

    Joined:
    Nov 7, 2011
    Messages:
    155
    Likes Received:
    145
    you could use a timer
     
  6. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    621
    Likes Received:
    63
    Location:
    CyberLand
    I'm using VB.NET
     
  7. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    621
    Likes Received:
    63
    Location:
    CyberLand
    don't know how ?!!could you help sockpuppet?
    need to do like this:

    code to put username
    wait 5 seconds
    code to put password
    wait 5 seconds
    code to signin
    wait 20 seconds
    .
    .
    .
     
  8. sockpuppet

    sockpuppet Junior Member

    Joined:
    Nov 7, 2011
    Messages:
    155
    Likes Received:
    145
    sorry, skipped vb.net day in school
    google is your friend
     
  9. roadhamster

    roadhamster Regular Member

    Joined:
    Mar 12, 2012
    Messages:
    300
    Likes Received:
    225
    While the sleep command runs your program isn't doing anything. Fix this by using a timer. Instead of "Sleep" fire the timer and while the timer runs do nothing. When the timer ends disable the timer and go on with your program. Don't forget to add a "doevents" or something while your timer runs.

    - Create a waitloop
    - While waitloop runs hold program
    - When waitloop ends continue with the next command

    In good old VB6 like this:

    timer1.interval=x milliseconds
    timer1.enabled=true
    do while timer1.enabled=true
    doevents
    loop

    Sub Timer1
    timer1.enabled=false
    end sub
     
    • Thanks Thanks x 1
    Last edited: Jun 9, 2014
  10. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    621
    Likes Received:
    63
    Location:
    CyberLand
    SOLVED i used a pause sub,thanks guys.