请检查我下面的代码:
Public Class tier1
Dim rnd As New System.Random()
Function build1(ByVal dt As DataTable) As String
Try
For i = 0 To 4
For ix As Integer = 0 To till Step 4
lstrn.Add(rnd.Next(ix, ix + 4))
Next
Dim cntx As Integer = 0
For Each x As Integer In lstrn
If (i = 0) Then
If (article(x).Split(ChrW(10)).Length > 2) Then
If (article(x).Split(ChrW(10))(0).Length > 300) Then
first.Add(article(x).Split(ChrW(10))(0))
cntx = cntx + 1
If (cntx = 25) Then
Exit For
End If
End If
End If
End If
lstrn.Clear()
Next
Dim fi as String = "{"
For dx As Integer = 0 To first.Count - 2
fi = fi & w.spinl(first(dx), "light") & "|"
Next
fi = fi & "}"
Return fi
Catch ex As Exception
End Try
End Function
End Class
现在看看我的调用代码:
Dim w As WaitCallback = New WaitCallback(AddressOf beginscn)
For var As Integer = 1 To NumericUpDown1.Value
Dim param(1) As Object
param(0) = lst
param(1) = var
ThreadPool.QueueUserWorkItem(w, param)
Next
sub
sub beginscn()
Dim scntxt As String = t1.buildtier1(dt)
end sub
现在明白我给了什么,我想要什么。假设我传递这样的数据表:
1,abcd,34,5
2,adfg,34,5
3,fhjrt,34,5
4,rtitk,34,5
我想要的是 {abcd|adfg|fhjrt|rtitk} 并且这个序列每次都应该是随机的。由于我传递了 50-100 个值并在 25 处退出循环,因此每个输出应该有一个不同的 25 个字符串序列,采用 {|} 格式,但它不是那样工作的。每次我得到相同的序列。
任何人都可以解释为什么它会这样做以及这个问题的任何可能的解决方案吗?
注意:我已经尝试在排队之前对数据表进行改组,但它仍然不起作用。