Today, I saw an example about "multithreading", and I felt pretty good, so I started my work.
Source: http://dev.21tx.com/2006/07/05/11760.html
Because I didn't see any images before, I just practiced it step by step based on the text introduction. It is a little different. If you are interested, you can do it yourself.
Source code: Http://files.cnblogs.com/zzc315/httpftp_20070808.rar
My development environment is Microsoft Visual Studio 2005, which is different from the development environment of the author (visual studio.net 2002 development environment and Windows XP operating system:
Reference: http://msdn2.microsoft.com/zh-cn/library/ms171728 (vs.80). aspx # mtps_dropdownfiltertext
Solution:
// Form1.cs
Delegate void setlistboxcallback (string ListBox );
......
Public void setlistbox (string ListBox)
{
// Invokerequired required compares the thread ID of
// Calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
If (this. listbox1.invokerequired)
{
Setlistboxcallback d = new setlistboxcallback (setlistbox );
This. Invoke (D, new object [] {ListBox });
}
Else
{
This. listbox1.items. Add (ListBox );
}
}
// Httpfile. CS
// Formm. listbox1.items. Add ("Thread" + threadh. tostring () + "start receiving ");
Formm. setlistbox ("Thread" + threadh. tostring () + "start receiving ");
1. I recently read some basic knowledge about multithreading. I think this example is classic and interesting. I would like to share it with you;
2. If you have any suggestions or comments on learning "multithreading" or related materials, thank you for your consideration.