如何在visual basic 2008中使用线程来优化线程 [英] How to use threading for optimise threading in visual basic 2008
本文介绍了如何在visual basic 2008中使用线程来优化线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一小段代码从指定目录加载图像并使用它们动态创建image-checkbox并添加到FlowLayoutPanel。现在我想使用带螺纹来更快地加载图像。我是新手,不知道如何使用线程。有人可以帮帮我吗?
我的代码:
I have a small piece of code to load images from specified directory and create image-checkbox dynamically with them and add to a FlowLayoutPanel. Now I want to useelp threading to load images faster. I am a newbie and don't know how to use threading. Can anybody help me?
My Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dlg As New FolderBrowserDialog
If dlg.ShowDialog = DialogResult.OK Then
TextBox1.Text = dlg.SelectedPath
For Each item As String In Directory.GetFiles(TextBox1.Text, "*.jpg")
Dim checkBox As New CheckBox
Dim original As Image = Image.FromFile(item)
Dim resized As Image = ResizeImage(original, New Size(78, 78))
original.Dispose()
checkBox.Size = New Size(117, 109)
checkBox.Text = (Path.GetFileName(item))
checkBox.Image = resized
checkBox.BackColor = Color.Gray
checkBox.ForeColor = Color.White
checkBox.TextAlign = ContentAlignment.BottomCenter
AddHandler checkBox.CheckedChanged, AddressOf myhandler2
FlowLayoutPanel1.Controls.Add(checkBox)
Next
End If
End Sub
我尝试过:
我不尝试任何事情。因为我对如何做到这一点一无所知。
What I have tried:
I do not try anything. As I don't have any idea on how to do that.
推荐答案
参见 vb.net线程 - Google搜索 [ ^ ]。
这篇关于如何在visual basic 2008中使用线程来优化线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文