2017-03-20 143 views
-4

誰かが私のコードをチェックしていますか? パラメータcountが一致しないことを示します。C#コード呼び出しパラメータ数が一致しません

void WriteFaceLog(string userID, string faceId, string size, string valid, string template) 
    { 
     if (lstvFace.InvokeRequired) 
     { 
      Action<string, string, string, string, string> action = WriteFaceLog; 
      this.Invoke(action, faceId, size, valid, template); 
     } 
     else 
     { 
      ListViewItem item = new ListViewItem(userID); 
      item.SubItems.AddRange(new[] { faceId, size, valid, template }); 
      lstvFace.Items.Add(item); 
     } 
    } 
+2

'Invoke'に' userId'がありません。 – Sinatr

答えて

0

(任意のスレッドからメソッドを実行している簡素化するために設計された)典型的な自動起動パターンますあなたのケースでは、次のようになります。与えられた場合には

void WriteFaceLog(string userID, string faceId, string size, string valid, string template) 
{ 
    if (this.InvokeRequired) // you can use lstvFace instead of this, it doesn't matter as both are in same thread, you can also omit this 
     this.Invoke((MethodInvoker)delegate { WriteFaceLog(userID, faceId, size, valid, template); }); 
    else 
    { 
    } 
} 

あなたが任意のパラメータを欠場する可能性は低い(ただそれらを再パスする)。

関連する問題