M
Michael M.
I have the following code (listed at bottom of post) that pings a small
range of IP address to see which ones are alive.
To speed things up a little I am trying to use more than one thread, problem
is instead of returning:
192.168.0.1 online
192.168.0.2 offline
192.168.0.3 online
192.168.0.4 offline
It seems to return this (like the IPHostOctet is not incrementing before I
fire of the worker processes)
It is almost like the the Argument is passed "by ref" meaning by the time
the first thread fires it has been incremened 4 times and holds that value
the same value in each bgworker / ping object.
or mabye it only gets incremened once per loop? It is declred outside the
procedure and is of type Integer
FYI: inside the do work methods of the Background workers it just appends
the incrmeting network host byte / octect like:
reply = Pinger.Ping (192.168.0. & IpHostOctect.tostring)
192.168.0.1 offline
192.168.0.1 offline
192.168.0.1 offline
192.168.0.1 offline
192.168.0.2 offline
192.168.0.2 offline
The code that calls the Background workers (it is within a loop in the
actual program)
If bgwPinger.IsBusy = False Then
IpHostOctect += 1
bgwPinger.RunWorkerAsync(IpHostOctect)
End If
If bgwPinger2.IsBusy = False Then
IpHostOctect += 1
bgwPinger2.RunWorkerAsync(IpHostOctect)
End If
If bgwPinger3.IsBusy = False Then
IpHostOctect += 1
bgwPinger3.RunWorkerAsync(IpHostOctect)
End If
If bgwPinger4.IsBusy = False Then
IpHostOctect += 1
bgwPinger4.RunWorkerAsync(IpHostOctect)
End If
range of IP address to see which ones are alive.
To speed things up a little I am trying to use more than one thread, problem
is instead of returning:
192.168.0.1 online
192.168.0.2 offline
192.168.0.3 online
192.168.0.4 offline
It seems to return this (like the IPHostOctet is not incrementing before I
fire of the worker processes)
It is almost like the the Argument is passed "by ref" meaning by the time
the first thread fires it has been incremened 4 times and holds that value
the same value in each bgworker / ping object.
or mabye it only gets incremened once per loop? It is declred outside the
procedure and is of type Integer
FYI: inside the do work methods of the Background workers it just appends
the incrmeting network host byte / octect like:
reply = Pinger.Ping (192.168.0. & IpHostOctect.tostring)
192.168.0.1 offline
192.168.0.1 offline
192.168.0.1 offline
192.168.0.1 offline
192.168.0.2 offline
192.168.0.2 offline
The code that calls the Background workers (it is within a loop in the
actual program)
If bgwPinger.IsBusy = False Then
IpHostOctect += 1
bgwPinger.RunWorkerAsync(IpHostOctect)
End If
If bgwPinger2.IsBusy = False Then
IpHostOctect += 1
bgwPinger2.RunWorkerAsync(IpHostOctect)
End If
If bgwPinger3.IsBusy = False Then
IpHostOctect += 1
bgwPinger3.RunWorkerAsync(IpHostOctect)
End If
If bgwPinger4.IsBusy = False Then
IpHostOctect += 1
bgwPinger4.RunWorkerAsync(IpHostOctect)
End If