sleep?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • HockeyFan

    #1

    sleep?

    I'm new to VB.Net. Wondering how you do a sleep for x milliseconds and then
    continue executing on the next line? This was done in VB6 and wondering how
    it's done in VB.Net.
  • guy

    #2
    RE: sleep?

    look at:-
    System.Threadin g.Thread.Curren tThread.Sleep( )

    hth

    --guy--

    "HockeyFan" wrote:
    [color=blue]
    > I'm new to VB.Net. Wondering how you do a sleep for x milliseconds and then
    > continue executing on the next line? This was done in VB6 and wondering how
    > it's done in VB.Net.[/color]

    Comment

    • zacks@construction-imaging.com

      #3
      Re: sleep?

      System.Threadin g

      Imports System.Threadin g

      public sub mySub

      'do something before waiting
      Thread.Sleep(20 00) ' sleeps for 2000 milliseconds
      'do something after waiting

      end sub

      Can get you in trouble if you have multiple threads unless you are
      careful.

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: sleep?

        "guy" <guy@discussion s.microsoft.com > schrieb:[color=blue]
        > System.Threadin g.Thread.Curren tThread.Sleep( )[/color]

        Better simply call 'System.Threadi ng.Thread.Sleep ', which will block
        execution of the thread calling the method.

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        • CMM

          #5
          Re: sleep?

          I don't remember this being available in VB6?!
          I know you could do it using the Win32 Sleep API... but it wasn't part of
          VB6.

          --
          -C. Moya

          "HockeyFan" <HockeyFan@disc ussions.microso ft.com> wrote in message
          news:DDCA6E0A-0B81-4A8C-8D30-251002520372@mi crosoft.com...[color=blue]
          > I'm new to VB.Net. Wondering how you do a sleep for x milliseconds and
          > then
          > continue executing on the next line? This was done in VB6 and wondering
          > how
          > it's done in VB.Net.[/color]


          Comment

          • m.posseth

            #6
            Re: sleep?

            Imports System

            Public Module modmain

            Sub Main()

            Console.WriteLi ne("I wait five seconds")

            System.Threadin g.Thread.Sleep( 5000)

            Console.WriteLi ne("five seconds have passed")

            End Sub

            End Module





            regards



            Michel Posseth [MCP]









            "CMM" <cmm@nospam.com > wrote in message
            news:%232MXUOOM GHA.2064@TK2MSF TNGP09.phx.gbl. ..[color=blue]
            >I don't remember this being available in VB6?!
            > I know you could do it using the Win32 Sleep API... but it wasn't part of
            > VB6.
            >
            > --
            > -C. Moya
            > www.cmoya.com
            > "HockeyFan" <HockeyFan@disc ussions.microso ft.com> wrote in message
            > news:DDCA6E0A-0B81-4A8C-8D30-251002520372@mi crosoft.com...[color=green]
            >> I'm new to VB.Net. Wondering how you do a sleep for x milliseconds and
            >> then
            >> continue executing on the next line? This was done in VB6 and wondering
            >> how
            >> it's done in VB.Net.[/color]
            >
            >[/color]


            Comment

            • CMM

              #7
              Re: sleep?

              VB6?

              The .NET answer had already been posted. I was asking about the OT
              mentioning VB6.

              --
              -C. Moya



              Comment

              • m.posseth

                #8
                Re: sleep?

                well in my newsgroup reader the .Net answer wasn`t showed i see now that
                this was on a seperate thread


                about the vb6 thingy

                afaik this can only be done like this

                Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

                Private Sub Command1_Click( )



                Me.Caption = "Your system will sleep 5 sec."

                'Sleep for 5000 milliseconds

                Sleep 5000

                Me.Caption = ""

                End Sub

                Private Sub Form_Load()

                Me.Caption = ""

                Command1.Captio n = "Sleep ..."

                End Sub

                regards

                Michel Posseth [MCP]
                "CMM" <cmm@nospam.com > wrote in message
                news:ODYaz0iMGH A.1832@TK2MSFTN GP11.phx.gbl...[color=blue]
                > VB6?
                >
                > The .NET answer had already been posted. I was asking about the OT
                > mentioning VB6.
                >
                > --
                > -C. Moya
                > www.cmoya.com
                >[/color]


                Comment

                Working...