我的多线程程序不工作,下拉列表要么为空,要么只加载一个。
Imports System.Threading
Partial Class _Default
Inherits System.Web.UI.Page
Public Delegate Sub WaitCallback(ByVal state As Object)
Private Sub LongTimeTask(ByVal s As Object)
Dim i As Integer
Dim str As String
str = s.ToString
For i = 0 To 1000
str = str + "--" + str
Next
End Sub
Protected Sub Button1_Click(ByVal sender As _
Object, ByVal e As System.EventArgs) Handles Button1.Click
If ThreadPool.QueueUserWorkItem( _
New WaitCallback(AddressOf LongTimeTask), TextBox1.Text) _
Then
Label2.Text = "Queued successfully"
Else
Label2.Text = "Failed"
End If
End Sub