2016-08-02 3 views
0

그래서 URL로 보낸 후 브라우저 컨트롤의 문서에서 null 참조가 나타납니다. 나는 그 문서가 로딩이 끝나지 않았기 때문이라고 생각했다.브라우저 제어 후 C# Enacting 메서드로드 완료?

enter image description here

사람이 어떻게 가야 말해시겠습니까 그러나

string[] m_ArgCache = null; 
    internal void AutomateThreadCreation(string title, string content) 
    { 
     SendToNewThreadByIndex(); 

     m_ArgCache = new string[] { title, content }; 
     Browser.DocumentCompleted += Browser_DocumentCompleted; 
    } 

    void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) 
    { 
     if(m_ArgCache != null) 
      AttemptPost(m_ArgCache[0], m_ArgCache[1]); 
    } 

, 나는 여전히 널 오류를 받고 있어요 : 그래서 이벤트 처리기를 추가?

편집 :

나는 또한이 방법은 내가 페이지에 이미있어 제대로 경우 작동 추가해야합니다. 문제는 페이지로 이동 한 다음 방법을 시도 할 때 발생합니다.

답변

0

해결책은 DocumentCompleted 대신 Browser.Validated에 대한 이벤트 처리기를 만드는 것이 었습니다.

string[] m_ArgCache = null; 
    internal void AutomateThreadCreation(string title, string content) 
    { 
     SendToNewThreadByIndex(); 

     m_ArgCache = new string[] { title, content }; 
     Browser.Validated += Browser_Validated; 
    } 

    void Browser_Validated(object sender, EventArgs e) 
    { 
     if (m_ArgCache != null) 
      AttemptPost(m_ArgCache[0], m_ArgCache[1]); 
    }