如何线程ping请求以加快完成时间 [英] how to thread ping requests for faster completion time

查看:115
本文介绍了如何线程ping请求以加快完成时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ping检查多台服务器,但是这需要很长时间,所以任何人都知道如何使其更快?谢谢.

I am trying to check multiple servers using ping but it take long time so anyone know how to make it faster ?? Thanks.

Dim ping0 As New Ping
        Try
            Dim pingreply = ping0.Send(lblServer0.Text, 200)
            If pingreply.Status = IPStatus.Success Then
                imgServer0.ImageUrl = ("~/Images/green_light.png")
            End If
        Catch ex As Exception
            imgServer0.ImageUrl = ("~/Images/red_light.png")
        End Try
        Dim ping1 As New Ping
        Try
            Dim pingreply = ping1.Send(lblServer1.Text, 200)
            If pingreply.Status = IPStatus.Success Then
                imgServer1.ImageUrl = ("~/Images/green_light.png")
            End If
        Catch ex As Exception
            imgServer1.ImageUrl = ("~/Images/red_light.png")
        End Try
        Dim ping2 As New Ping
        Try
            Dim pingreply = ping2.Send(lblServer2.Text, 200)
            If pingreply.Status = IPStatus.Success Then
                imgServer2.ImageUrl = ("~/Images/green_light.png")
            End If
        Catch ex As Exception
            imgServer2.ImageUrl = ("~/Images/red_light.png")
        End Try

推荐答案

尝试:
http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/multithreading-pings-and-showing-them [ ^ ]
Try:
http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/multithreading-pings-and-showing-them[^]


看看你在做什么.除ping不成功而不是异常的情况外,您总是会在成功和异常上分配〜/Images/green_light.png".为什么?这似乎没有意义.您不能真正提高吞吐量,因为它主要取决于您要ping的主机,尤其是这台服务器很忙.如果远程主机确实是一个瓶颈,而您又有一个瓶颈,则可以通过将每个主机放在单独的线程中来尝试在一定程度上提高吞吐量.

—SA
Look what you are doing. You always assign "~/Images/green_light.png", on success and exception, except the cases of unsuccessful ping and not exception. Why? It does not seem to make sense. You cannot really improve throughput, because it mostly depends on the host you are pinging, especially this is some busy server. If the remote host is really a bottleneck, and you have more then one, you can try to improve throughput to certain extent by doing it with each host in separate thread.

—SA


这篇关于如何线程ping请求以加快完成时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆