Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. wait process , please help me

wait process , please help me

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpdatabasetutorial
4 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    darkyro
    wrote on last edited by
    #1

    hi i need help to how wait the process finish. for example.

    pc : is a string "contain ip pc"
    position : is integer "contain index number to know how item will change the imageindex of current item in other listviewitem1

    for each item as listviewitem in listview1.items
    pc = item.ToolTipText
    position = item.index

    ping_to_host() ' here i have a sub created to ping ip and in sub he change the imageindex in the other listview ( for exmaple : 0 is "off" and 1 is "on" )
    next

    OK the problem is not here , the problem is when he get de position and pc name he go to the ping_to_host() sub . this process is very fast for ping process can complete of the first ip recepted. when he are pinging to ip "1" the process can't complete because don't have time for complete . how i can set a time or wait to ping process complete for can jump for next item. SORRY , SO LONG TIME NO SPEAK ENGLISH

    realJSOPR D 2 Replies Last reply
    0
    • D darkyro

      hi i need help to how wait the process finish. for example.

      pc : is a string "contain ip pc"
      position : is integer "contain index number to know how item will change the imageindex of current item in other listviewitem1

      for each item as listviewitem in listview1.items
      pc = item.ToolTipText
      position = item.index

      ping_to_host() ' here i have a sub created to ping ip and in sub he change the imageindex in the other listview ( for exmaple : 0 is "off" and 1 is "on" )
      next

      OK the problem is not here , the problem is when he get de position and pc name he go to the ping_to_host() sub . this process is very fast for ping process can complete of the first ip recepted. when he are pinging to ip "1" the process can't complete because don't have time for complete . how i can set a time or wait to ping process complete for can jump for next item. SORRY , SO LONG TIME NO SPEAK ENGLISH

      realJSOPR Offline
      realJSOPR Offline
      realJSOP
      wrote on last edited by
      #2

      Put the ping code into a thread and join the thread... That should wait for the thread to finish before processing continues.

      .45 ACP - because shooting twice is just silly
      -----
      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

      1 Reply Last reply
      0
      • D darkyro

        hi i need help to how wait the process finish. for example.

        pc : is a string "contain ip pc"
        position : is integer "contain index number to know how item will change the imageindex of current item in other listviewitem1

        for each item as listviewitem in listview1.items
        pc = item.ToolTipText
        position = item.index

        ping_to_host() ' here i have a sub created to ping ip and in sub he change the imageindex in the other listview ( for exmaple : 0 is "off" and 1 is "on" )
        next

        OK the problem is not here , the problem is when he get de position and pc name he go to the ping_to_host() sub . this process is very fast for ping process can complete of the first ip recepted. when he are pinging to ip "1" the process can't complete because don't have time for complete . how i can set a time or wait to ping process complete for can jump for next item. SORRY , SO LONG TIME NO SPEAK ENGLISH

        D Offline
        D Offline
        darkyro
        wrote on last edited by
        #3

        i don't know how to insert. the button to shearch is here :

        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim posicaoatual As String
        Dim itemselecionado As String
        Dim t As Thread
        For Each items As ListViewItem In lstrefresh.Items
        items.Selected = True
        For Each selecionado As ListViewItem In lstrefresh.SelectedItems
        Main.PosicaoEstacaoNoList = selecionado.Index
        Main.estacaoSelected = selecionado.SubItems.Item(2).Text
        Control.Ping_to_host()

                    't = New Thread(AddressOf processo.Ping\_to\_host)
                    ' MessageBox.Show(Main.estacaoSelected & vbCrLf & Main.PosicaoEstacaoNoList)
                    't.Start()
        
                Next
        
            Next
        
        End Sub
        

        here i have the ping code :

        Public Sub Ping_to_host()

            Main.RichTextBox1.Clear()
            Dim vez As String = 3
        
            'Dim host As String = Main.estacaoSelected
            Dim ip As String = Main.estacaoSelected
            Dim ans, ans2
            Dim i As Integer
            'ans = InputBox("Digite o Endereço desejado", "Host", "www.google.com.br")
            ans = ip
            If ans = "" Then
        
                Exit Sub
            Else
                host = ans.ToString
                'ans2 = InputBox("Pro favor digite a quantidade de vezes para pingar", "Ping count", "1")
                ans2 = vez
                If ans2 = "" Then
                    Exit Sub
                Else
                    vezes = ans2.ToString
                    ' For i = 0 To System.Convert.ToInt32(vezes.Text)
                    ' For i = 1 To System.Convert.ToInt32(vezes.Text)
                    Me.Timer3.Enabled = True
        
        
                    'Me.Timer3.Start()
                    'Next
        
                End If
        
            End If
        
        
        End Sub
        
        Private Sub Timer3\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
            Dim lstText As String
            Dim i As Integer
        
        
            'Me.Timer3.Enabled = True
            'Me.Timer3.Start()
            For i = 1 To System.Convert.ToInt16(vezes)
        
        
                Try
                    If My.Computer.Network.Ping(Me.host) Then
                        'MsgBox("Ping successfull", MsgBoxStyle.Information, "Successfull")
                        lstText = Now() & "  ---  " & host & " -- " & "Ping OK" & vbCrLf
                        ' MsgBox("oi")
                        Main.RichTextBox1.Text = LTrim
        
        D 1 Reply Last reply
        0
        • D darkyro

          i don't know how to insert. the button to shearch is here :

          Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
          Dim posicaoatual As String
          Dim itemselecionado As String
          Dim t As Thread
          For Each items As ListViewItem In lstrefresh.Items
          items.Selected = True
          For Each selecionado As ListViewItem In lstrefresh.SelectedItems
          Main.PosicaoEstacaoNoList = selecionado.Index
          Main.estacaoSelected = selecionado.SubItems.Item(2).Text
          Control.Ping_to_host()

                      't = New Thread(AddressOf processo.Ping\_to\_host)
                      ' MessageBox.Show(Main.estacaoSelected & vbCrLf & Main.PosicaoEstacaoNoList)
                      't.Start()
          
                  Next
          
              Next
          
          End Sub
          

          here i have the ping code :

          Public Sub Ping_to_host()

              Main.RichTextBox1.Clear()
              Dim vez As String = 3
          
              'Dim host As String = Main.estacaoSelected
              Dim ip As String = Main.estacaoSelected
              Dim ans, ans2
              Dim i As Integer
              'ans = InputBox("Digite o Endereço desejado", "Host", "www.google.com.br")
              ans = ip
              If ans = "" Then
          
                  Exit Sub
              Else
                  host = ans.ToString
                  'ans2 = InputBox("Pro favor digite a quantidade de vezes para pingar", "Ping count", "1")
                  ans2 = vez
                  If ans2 = "" Then
                      Exit Sub
                  Else
                      vezes = ans2.ToString
                      ' For i = 0 To System.Convert.ToInt32(vezes.Text)
                      ' For i = 1 To System.Convert.ToInt32(vezes.Text)
                      Me.Timer3.Enabled = True
          
          
                      'Me.Timer3.Start()
                      'Next
          
                  End If
          
              End If
          
          
          End Sub
          
          Private Sub Timer3\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
              Dim lstText As String
              Dim i As Integer
          
          
              'Me.Timer3.Enabled = True
              'Me.Timer3.Start()
              For i = 1 To System.Convert.ToInt16(vezes)
          
          
                  Try
                      If My.Computer.Network.Ping(Me.host) Then
                          'MsgBox("Ping successfull", MsgBoxStyle.Information, "Successfull")
                          lstText = Now() & "  ---  " & host & " -- " & "Ping OK" & vbCrLf
                          ' MsgBox("oi")
                          Main.RichTextBox1.Text = LTrim
          
          D Offline
          D Offline
          darkyro
          wrote on last edited by
          #4

          i resolved this problem using "While"

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups