Requirements:
1, in the process of writing, as a result, real-time display in a listview, form not feign death,
2, by setting the maximum number of threads, according to the maximum number of threads concurrent writes,
3, three parameters through the loop to,
4, when written to, through the sequential writes, there are currently no written in sequence,
Attach the current code, bosses, please give directions,
using System;
Using System. Collections. Generic;
Using System.Com ponentModel;
Using System. The Data;
Using System. Drawing;
Using System. The Text;
Using System. Windows. Forms;
using System.Threading;
The namespace ThreadStudy
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent ();
}
Private void button1_Click (object sender, EventArgs e)
{
For (int I=0; I & lt; 10000; I++)
{
Person p=new Person (I, "liu bei" + i.T oString (), "liubei123456");
ThreadPool. QueueUserWorkItem (new WaitCallback (ThreadFunc), p);
}
}
Private delegate void MyInvokeDelegate (object name);
Private void Test (object o)
{
Person p=o as Person;
ListView1. Items. The Add (new ListViewItem (new string [] {p.I which oString (), p.N ame, Thread. The CurrentThread. ManagedThreadId. The ToString ()}));
}
Public void ThreadFunc object (b)
{
MyInvokeDelegate myInvoke=new MyInvokeDelegate (Test);
Enclosing the BeginInvoke (myInvoke, b);
}
}
Public class Person
{
Public Person (int id, string name, string password) {id=id; Name=Name; Password=Password; }
Public int Id {get; The set; }
Public string Name {get; The set; }
Public string Password {get; The set; }
}
}