[英]Overload resolution failed because no accessible `Sleep` can be called with these arguments
您需要将数字(双精度)转换为timeSpan:
Dim sleepTime As Timespan = TimeSpan.FromSeconds(infoReader.Lenth/1000)
The result a division operation ( infoReader.Length / 1000
) is a floating point number ( Double
in our case since FileInfo.Length
property is of type Long
). 结果除法运算(
infoReader.Length / 1000
)是一个浮点数(在本例中为Double
,因为FileInfo.Length
属性的类型为Long
)。
On the other hand, the Threading.Thread.Sleep()
overload you're most likely wanting to use expects an Int
parameter. 另一方面,您最有可能要使用的
Threading.Thread.Sleep()
重载期望使用Int
参数。
Cast the division result to Int
explicitly (is the files are not too big): 将除法结果显式转换为
Int
(文件不是太大):
Threading.Thread.Sleep(CInt(infoReader.Length / 1000))
Or use the second overload accepting TimeSpan
, using the FromMilliseconds
method which accepts Double
: 或者使用第二个重载接受
TimeSpan
,使用FromMilliseconds
方法接受Double
:
Threading.Thread.Sleep(TimeSpan.FromMilliseconds(infoReader.Length / 1000))
Divide it using the integer division. 用整数除法将其除。 The sleep function doesn't take a double as parameter.
sleep函数不使用double作为参数。
Threading.Thread.Sleep(infoReader.Length \ 1000)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.