Я пытаюсь следовать этому примеру из MSDN: http://msdn.microsoft.com/en-us/library/a1hetckb.aspx
Я думаю, что я делаю все, что они сделали, но я продолжаю получать эту ошибку: Несоответствие количества параметров
Вот мойкод:
Form1:
namespace ETL
{
public partial class Form1 : Form
{
private Thread myThread;
public delegate void delegatePrintoutProcess(string myString);
public delegatePrintoutProcess myDelegate2;
...
private void startParseToolStripMenuItem_Click(object sender, EventArgs e)
{
myDelegate2 = new delegatePrintoutProcess(updatePrintoutMethod);
myThread = new Thread(new ThreadStart(ThreadFunction));
myThread.Start();
}
public void updatePrintoutMethod(string text)
{
// this.richTextBox1.Text = text;
}
private void ThreadFunction()
{
parseFile myThreadClassObject = new parseFile(this);
myThreadClassObject.getFilePath = filePath;
myThreadClassObject.Run();
}
}
класс parseFile:
namespace ETL
{
public class parseFile
{
Form1 myFormControl1;
public parseFile(Form1 myForm)
{
//get a handle on the main form
myFormControl1 = myForm;
}
String myString;
public void Run()
{
for (int i = 1; i <= 5; i++)
{
myString = "Step number " + i.ToString() + " executed";
Thread.Sleep(400);
// Execute the specified delegate on the thread that owns
// 'myFormControl1' control's underlying window handle with
// the specified list of arguments.
myFormControl1.Invoke(myFormControl1.myDelegate,
new Object[] { myString }); //error here
}
}
}
Я почти уверен, что следовал приведенному примеру, поэтому не уверен, что происходитна.
Спасибо Джейсон