2013-09-21 67 views
-3

一類樣本:testHTTP.class在此代碼C#形式啓動線程

 public String httptest(object httptestx) 
     { 
     var data = (Tuple<string, string, string>)httptestx; 
     var s = data.Item1; 
     var k = data.Item2; 
     var p = data.Item3;   
     ............................ 

     } 

Form1的線程類無法啓動,請幫助我...:

private void button5_Click(object sender, EventArgs e) 
    { 
       for (Int32 i5 = 0; i5 < textBox5.Lines.Length; i5++) 
       { 
        var thr1 = new Thread(dfproJesiHttpClass.httptest()); 
        var data = new Tuple<string, string, string>(textBox6.Lines[i6].Trim(), textBox4.Lines[i4].Trim(), textBox5.Lines[i5].Trim()); 
        thr1.Start(data); 
        threads.Add(thr1); 
       } 
    } 

回答

2

我會感到驚訝如果代碼編譯。你需要改變這一行:

var thr1 = new Thread(dfproJesiHttpClass.httptest()); 

var thr1 = new Thread(dfproJesiHttpClass.httptest); 

假設dfproJesiHttpClass是一個實例,而不是類的名稱。