- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
When option strict is OFF, works fine. ON,我得到重载解析失败:
Dim _thread1 As Thread
Private Sub test2(boolTest As Boolean)
' Do something
End Sub
'
Private Sub test()
_thread1 = New Thread(AddressOf test2)
_thread1.Start(True)
End Sub
Overload resolution failed because no accessible 'New' can be called with these arguments:
'Public Sub New(start As System.Threading.ParameterizedThreadStart)': Option Strict On does not allow narrowing in implicit type conversions between method 'Private Sub test2(boolTest As Boolean)' and delegate 'Delegate Sub ParameterizedThreadingStart(obj As Object)'.
'Public Sub New(start As System.Threading.ThreadStart)': Method 'Private Sub test2(boolTest As boolean)' does not have a signature compatible with delegate 'Delegate Sub ThreadStart()'.
最佳答案
当你以这种方式启动一个线程时,你的函数必须有一个或更少的参数。如果指定一个参数,它必须来自类型 Object
.
在您的函数中,您可以简单地将此对象参数转换为您的数据类型:
private sub startMe(byval param as Object)
dim b as Boolean = CType(param, Boolean)
...
end sub
public class Parameters
dim paramSTR as String
dim paramINT as Integer
end class
private sub startMe(byval param as Object)
dim p as Parameters = CType(param, Parameters)
p.paramSTR = "foo"
p.paramINT = 0
...
end sub
dim t as new Thread(AddressOf startMe)
dim p as new Parameters
p.paramSTR = "bar"
p.oaramINT = 1337
t.start(p)
关于vb.net - 如何在VB中创建一个带有参数的函数的新线程AddressOf?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30162382/
嘿。本周的一个教程,其中一个问题要求通过使用其他函数 formatLine 和 formatList 创建一个函数 formatLines,以格式化行列表。 我的代码是这样的; type Line =
我是一名优秀的程序员,十分优秀!