[实践篇]+[转]用C#实现HTTP协议下的多线程文件传输

今天看到一篇关于“多线程”的例子,感觉比较形象,于是动手操作了一下。

原文出处:http://dev.21tx.com/2006/07/05/11760.html

由于之前自己看到的没有图片,于是就是凭文字介绍按部就班地实践了一下;故有点差异,有兴趣地话自己也可以动手完善一下。

源代码下载地址:https://files.cnblogs.com/zzc315/httpftp_20070808.rar

我的开发环境是:Microsoft Visual Studio 2005;故和作者的开发环境(Visual Studio.net 2002开发环境及Windows xp 操作系统)有所差异,遇到:


资料参考:http://msdn2.microsoft.com/zh-cn/library/ms171728(VS.80).aspx#Mtps_DropDownFilterText

解决方法:
         //Form1.cs
        delegate void SetListBoxCallback(string listBox);
         ……         
        public void SetListBox(string listBox)
        {
            // InvokeRequired required compares the thread ID of the
            // 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("线程" + threadh.ToString() + "开始接收");
         formm.SetListBox("线程" + threadh.ToString() + "开始接收");

         1.最近在看一些“多线程”方面的基本知识,感觉这个例子比较经典,且比较有趣,所有和大家分享一下;
         2.如有学习“多线程”方面好的建议或意见,或相关资料,感谢大家一同来探讨学习。
posted on 2007-08-09 00:24  淡泊江湖  阅读(1103)  评论(0编辑  收藏  举报