TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ronald Abellano
NA
161
37.4k
Why does counting is not consistent in Parallel.For?
Dec 23 2018 3:07 AM
var items = Enumerable.Range(0, 20);
int
cnt = 0;
Parallel.For(0, items.Count(), (
int
i) => {
WorkOnItem(items.ToArray()[i]);
cnt++;
});
static
void
WorkOnItem(
object
item)
{
Console.WriteLine(
"Working on item:"
+ item);
Thread.Sleep(10);
}
Does it mean the thread failed?
Reply
Answers (
1
)
Cross-thread operation not valid: Control ‘dataGridView1’
C# Windows Form - Serial Port problem / BackgroundWorker