2017-11-24 2 views
0

내 코드가C 번호 메시지 : 개체 참조가

잘못된 코드는 "개체 참조가 필요합니다"

를 컴파일하기 전에 다음과 같은 오류 메시지가 표시됩니다 (Control.Invoke로)가 필요합니다 : 사람은이 문제를 해결하는 방법을 알고 있나요 ...

Control.Invoke(new invokeDelegate(invokeMethod)); 

은 내가 static invokeMethod 전에 인스턴스를 넣어했지만 작동하지 않는 이유는 무엇입니까?

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 
     } 
    } 
} 

답변

관련 문제