如何使用我的代码减少GUI延迟?示例欢迎 [英] How can I reduce GUI Lag with my code? Examples Welcome

查看:118
本文介绍了如何使用我的代码减少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">

推荐答案

我已经解决了这个问题,我遇到了计时器问题。
I have resolved the issue, I ran into timer problems.


我修复了此代码中来自计时器的延迟。
I fixed the lag that was coming from the timer in this code.


这篇关于如何使用我的代码减少GUI延迟?示例欢迎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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