My code shows the following error message before compiling
"An object reference is required"
the wrong code is:
Control.Invoke(new invokeDelegate(invokeMethod));
I put a static
before invokeMethod
instance but it doesn't work...
Does anyone know how to fix this?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Thread invokeThread;
private delegate void invokeDelegate();
private void StartMethod()
{
//Code C
Control.Invoke(new invokeDelegate(invokeMethod));
//Code D
}
private void invokeMethod()
{
//Code E
}
private void button1_Click(object sender, EventArgs e)
{
//Code A
invokeThread = new Thread(new ThreadStart(StartMethod));
invokeThread.Start();
//Code B
}
}
}