本文介绍了如何使用我的代码减少GUI延迟?示例欢迎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim ip = "www.google.com"
Dim timeout = 1000
Dim sw = New Stopwatch()
Try
Dim ping As Long = -1
sw.Start()
If My.Computer.Network.Ping(ip, timeout) Then
sw.Stop()
ping = sw.ElapsedMilliseconds
End If
If ping < 0 Then
Label2.Text = "Timed Out"
Label2.BackColor = Color.Brown
Label2.ForeColor = Color.White
ElseIf ping < 200 Then
Label2.Text = "Good Connection"
Label2.BackColor = Color.Green
Else
Label2.Text = "Bad Connection"
Label2.BackColor = Color.Red
End If
Catch ex As Exception
Label2.Text = ex.Message
Label2.BackColor = Color.Red
Console.WriteLine(ex.ToString())
End Try
End Sub
End Class
<pre lang="vb"><pre lang="vb"><pre lang="vb">
推荐答案
这篇关于如何使用我的代码减少GUI延迟?示例欢迎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!