vb.net画图问题
cpu占用率尽达100%。如何改进程序?谢谢老师们
Public Class Form1
Public f As Thread
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
End
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
f = New Thread(AddressOf draw)
f.Start()
End Sub
Private Sub draw()
Dim x As Integer = 0
Dim y As Integer = 100
Dim b As Bitmap = New Bitmap(Me.picEMG.Width, Me.picEMG.Height, Imaging.PixelFormat.Format32bppArgb)
Dim G As Graphics = Graphics.FromImage(b)
G.Clear(Color.White)
G.TranslateTransform(0, picEMG.Height)‘picEMG是Picturebox的名字
Do
G.DrawLine(Pens.Blue, New Point(x, y), New Point(x + 2, -(y - 10)))
x += 2
y -= 10
If y = 0 Then
y = 100
End If
If x = Me.picEMG.Width Then
G.Clear(Color.White)
x = 0
End If
Me.picEMG.Image = b
'G.Dispose()
Loop
End Sub
End Class