如何使用vb.net的多线程

cih006 2005-04-16 08:33:11
如题
...全文
165 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
水如烟 2005-04-16
  • 打赏
  • 举报
回复
哈。等CSDNsuperman(Sky)先生来解答这个问题吧
CSDNsuperman 2005-04-16
  • 打赏
  • 举报
回复
ding
3tzjq 2005-04-16
  • 打赏
  • 举报
回复
private sub poll
writeline("Threading...")
end sub

private sub Test
Dim i As Integer
For i = 1 To 10 '还是少点吧!
Dim t As New System.Threading.Thread(AddressOf poll)
t.Start()
Next
end sub
landlordh 2005-04-16
  • 打赏
  • 举报
回复
eg.

Dim i As Integer
For i = 1 To 10000 '一次投一万,你可要耐心点哦
Dim t As New System.Threading.Thread(AddressOf poll)
t.Start()
Next
exboy 2005-04-16
  • 打赏
  • 举报
回复
参考 System.Threading 命名空间下面的类!
HKMAPLE 2005-04-16
  • 打赏
  • 举报
回复
友情顶!
ray680719 2005-04-16
  • 打赏
  • 举报
回复
Imports System.data
Imports System.Data.SqlClient
Imports System.Threading
'穷人的多线程查询处理器
Public Class PoorMansQueryProcess
'Global DataSet Obiect
Dim ds As DataSet
Public Sub main()
'create the new data set here,
'otherwise then threads willtru to create it
'this is "Shared",so you need to be careful
'that the threads do nto hose the instance
ds = New DataSet("Customers")
'create t1 and t2 threads
Dim t1 As New Thread(AddressOf Get_Suppliers)
Dim t2 As New Thread(AddressOf Get_Products)
'start new threads
t1.Start()
t2.Start()
'Wait for threads to finish up
t1.Join() '阻塞调用线程,直到到某个线程终止为止
'create the relationship between the two data sources with the data relation object
Dim dr As DataRelation
Dim dc1, dc2 As DataColumn
'get tje parent and child columns of the two tables.
dc1 = ds.Tables("Suppliers").Columns("SupplierID")
dc2 = ds.Tables("Products").Columns("SupplierID")
dr = New System.Data.DataRelation("match", dc1, dc2)
'add the relationship
ds.Relations.Add(dr)
ds.WriteXml("e:\netstudy\ado.xml")
MsgBox("Finito")

End Sub
Sub Get_Suppliers()
'***
'Connection to Server A
'***
Dim strCN As String
strCN = "uid=sa;pwd=;database=northwind;server="
Dim cn As SqlConnection = New SqlConnection(strCN)
Dim adpSuppliers As SqlDataAdapter = New SqlDataAdapter
adpSuppliers.TableMappings.Add("Table", "Suppliers")
Dim cmdSuppliers As SqlCommand = New SqlCommand("select * from suppliers", cn)
cmdSuppliers.CommandType = CommandType.Text
adpSuppliers.SelectCommand = cmdSuppliers
adpSuppliers.Fill(ds)
cn.Open()
End Sub
Sub Get_Products()
'***
'Connection to Server A
'***
Dim strCN As String
strCN = "uid=sa;pwd=;database=northwind;server="
Dim cn As SqlConnection = New SqlConnection(strCN)
Dim adpProducts As SqlDataAdapter = New SqlDataAdapter
adpProducts.TableMappings.Add("Table", "Products")
Dim cmdSuppliers As SqlCommand = New SqlCommand("select * from suppliers", cn)
cmdSuppliers.CommandType = CommandType.Text
adpProducts.SelectCommand = cmdSuppliers
adpProducts.Fill(ds)
cn.Close()
End Sub

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧