multi-thread

  • Thread starter Thread starter Microsoft
  • Start date Start date
M

Microsoft

I have an app that checks to see if I can ping, then hit the registry of a
few hundred machines. In its current form it goes down the list
sequentially one at a time.. Is there a way to do more than one machine at a
time?
I've seen tools that do this, not sure if you can multithread in VB.net.


Thanks...
 
Sure you can do multi-threading in VB.NET. Here's a simple console
application that might help show you how:

Imports System.Threading

Module Module1
Sub Main()
Dim threads(9) As Thread
Dim d(9) As DoWork
For i As Integer = 0 To 9
d(i) = New DoWork
d(i).ipAddress = "192.168.1." & i
threads(i) = New Thread(AddressOf d(i).MyMethod)
threads(i).Start()
Next

Dim message As String
For i As Integer = 0 To 9
threads(i).Join()
Console.WriteLine(d(i).status)
Next
End Sub
End Module

Public Class DoWork
Public ipAddress As String
Public status As String

Public Sub MyMethod()
status = "pinged:" & ipAddress
End Sub

End Class

Your ping and registry code would go in DoWork.MyMethod

Scott Swigart
blog - http://ea.3leaf.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top