arvind
arvind

Reputation: 11

Threads, Queue and a serious headache

I am making a program for days but nothing seems to be working. I want to run (n threads=user sepecified threads ie 1-100) on a listview which has 1st field as email (the list is of 10000 records). Now I want to verify each email and add on the 2nd column the thread id and on the third column the result whether the email is valid or not can anybody help me? With some code and explanation. thanx

Upvotes: 1

Views: 116

Answers (2)

Henk Holterman
Henk Holterman

Reputation: 273314

First of all, don't use a ListView as a datastructure. Bind it to some List<MyClass>.

Then run your Threads on the ThreadPool (<= .NET 3.5) or using Tasks (.NET4).

The learn about accessing your List<> in a thread-safe way. And then update your ListView using Control.Invoke(), or from a Timer

Upvotes: 2

Mathias
Mathias

Reputation: 15391

This sounds like a task for the Task Parallel Library. Rather than managing your threads by hand, it provides you with higher-level constructs which will properly use the thread pool and the hardware you have available, and parallelize work.

Upvotes: 1

Related Questions