[實踐篇]+用C#實現HTTP協議下的多線程檔案傳輸

來源:互聯網
上載者:User
今天看到一篇關於“多線程”的例子,感覺比較形象,於是動手操作了一下。

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

由於之前自己看到的沒有圖片,於是就是憑文字介紹按部就班地實踐了一下;故有點差異,有興趣地話自己也可以動手完善一下。

原始碼:http://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.如有學習“多線程”方面好的建議或意見,或相關資料,感謝大家一同來探討學習。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.