开发者

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 l开发者_如何学Pythonist 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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜