3 Replies - 461 Views - Last Post: 27 August 2013 - 04:15 AM Rate Topic: -----

#1 belgarion262  Icon User is offline

  • Prince of all (2) Saiyans

Reputation: 163
  • View blog
  • Posts: 947
  • Joined: 25-October 09

Problem with thread.sleep

Posted 23 August 2013 - 05:01 AM

The current code gives no errors, but doesn't give the the effect I'm looking for.
After each attack (yours or the enemies), a battle log message appears. I wish for the pause to occur after you've attack (and your message appears) but before they attack. So as to give the impresion the enemy is debating/deciding what to do.

Currently the code pauses before either log message comes up. So there is a pause, then both appear.


 
Private Sub btnYou_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYou.Click
        Call yourAttack()
        lblEnemyHp.Text = enemyHP
        btnYou.Enabled = False
        btnFireball.Enabled = False
        btnIceBall.Enabled = False
        btnLightningBall.Enabled = False
        btnAirBall.Enabled = False

        Call battleLog()
        System.Threading.Thread.Sleep(1000)
        Call ThemAttack()
    End Sub



Is there a different thing i should use other then sleep?

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with thread.sleep

#2 torind_2000  Icon User is online

  • D.I.C Regular
  • member icon

Reputation: 55
  • View blog
  • Posts: 284
  • Joined: 22-August 11

Re: Problem with thread.sleep

Posted 23 August 2013 - 05:17 AM

All thread.sleep does is effectively stopsyour code for the specified amount of time.
Maybe you are looking for a timer?

Here is a tutorial from AdamSpeight2008 on some uses.

This post has been edited by torind_2000: 23 August 2013 - 05:17 AM

Was This Post Helpful? 1
  • +
  • -

#3 dbasnett  Icon User is offline

  • D.I.C Addict

Reputation: 108
  • View blog
  • Posts: 601
  • Joined: 01-October 08

Re: Problem with thread.sleep

Posted 23 August 2013 - 05:52 AM

Use ControlName.Refresh after changing a control's text to display it before sleeping.
Was This Post Helpful? 1
  • +
  • -

#4 belgarion262  Icon User is offline

  • Prince of all (2) Saiyans

Reputation: 163
  • View blog
  • Posts: 947
  • Joined: 25-October 09

Re: Problem with thread.sleep

Posted 27 August 2013 - 04:15 AM

View Posttorind_2000, on 23 August 2013 - 06:17 AM, said:

All thread.sleep does is effectively stopsyour code for the specified amount of time.
Maybe you are looking for a timer?

Here is a tutorial from AdamSpeight2008 on some uses.


dbasnett said:



Thank you both. I must admit, the way thread.sleep was explained to me previously was obviously incorrect. Thank you for correcting my interpretation of it, and directing me towards a tutorial
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1