作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 C# 中,有一个 System.Threading.Tasks.Parallel.For(...)
这与 for
相同循环,没有顺序,但在多个线程中。问题是,它只适用于 long
和 int
, 我想与 ulong
一起工作.好的,我可以进行类型转换,但我在边框方面遇到了一些问题。
比方说,我想要一个来自 long.MaxValue-10
的循环至 long.MaxValue+10
(记住,我说的是 ulong
)。我该怎么做?
一个例子:
for (long i = long.MaxValue - 10; i < long.MaxValue; ++i)
{
Console.WriteLine(i);
}
//does the same as
System.Threading.Tasks.Parallel.For(long.MaxValue - 10, long.MaxValue, delegate(long i)
{
Console.WriteLine(i);
});
//except for the order, but theres no equivalent for
long max = long.MaxValue;
for (ulong i = (ulong)max - 10; i < (ulong)max + 10; ++i)
{
Console.WriteLine(i);
}
最佳答案
您可以随时写信给 Microsoft 并要求他们将 Parallel.For(ulong, ulong, Action
Parallel.For(-10L, 10L, x => { var index = long.MaxValue + (ulong) x; });
关于c# - Parallel.For 具有 64 位无符号索引 (UInt64),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4280074/
我是一名优秀的程序员,十分优秀!