2013-02-26 3 views
-2

내 문자열 메시지가 항상 null이고 내 결과 AsyncState가 null입니다. 누군가가 실수를 본 적이 있습니까?IAsyncResult out string always null

private void create_Incident(string computer_idn, string swidn_choice, 
          string swName_choice, string CI_Number, 
          string windows_user) 
{ 
    string msg_id = "" + computer_idn + "_" + swidn_choice + ""; 
    string username = "BISS"; 

    server3.ILTISAPI api = new server3.ILTISAPI(); 
    api.BeginInsertIncident(username, "", msg_id, "", "", "2857", 
     "BISS - Software Deployment", "", "", "NOT DETERMINED", "", "", "", "", 
     "", "", "5 - BAU", "3 - BAU", "", "Interface", "", "", "", "", "", "", 
     delegate(IAsyncResult r) { InsertIncidentCallback(api, r); }, null); 
} 

private void InsertIncidentCallback(server3.ILTISAPI api, 
            IAsyncResult result) 
{ 
    // do something and then: 
    string message; 
    api.EndInsertIncident(result, out message); 
} 

리턴 값 : 0 < 오류 (상기 정보는 상기 MSG 파라미터에서 찾아 볼 수있다). = 0 OK. = 1 OK. 세부 방법 :

public IAsyncResult BeginInsertIncident(string userName, string password, 
             string MsgId, string ThirdPartyRef, 
             string Type, string EmployeeId, 
             string ShortDescription, string Details, 
             string Category, string Service, 
             string OwnerGrp, string OwnerRep, 
             string SecondLevelGrp, 
             string SecondLevelRep, 
             string ThirdLevelGrp, 
             string ThirdLevelRep, string Impact, 
             string Urgency, string Priority, 
             string Source, string Status, 
             string State, string Solution, 
             string ResolvedDate, string Cause, 
             string Approved, AsyncCallback callback, 
             object asyncState); 

public int EndInsertIncident(IAsyncResult asyncResult, out string msg); 

오류 또는 확인이 있다면 내가는 MSG를 확인합니다.

+0

음 AsyncState *는 null입니다. 즉, BeginInsertIncident의 마지막 인수로 'null'을 전달합니다. –

+0

우리가 가장 좋아하는 검색 엔진에서 BeginInsertIncident & EndInsertIncident라는 용어의 유일한 발생률이이 질문이라는 것을 감안할 때, 우리는 어떻게 추측 할 것인가? -1 – spender

+0

질문에 편집을 참조하십시오. – mnlfischer

답변

0

비동기 상태는 사용자가 전달하는 예비 object입니다. 최종 매개 변수로 null을 전달하고 있습니다. 따라서 AsyncState은 항상 null이 될 것입니다.

null을 원하지 않으면 다른 매개 변수를 최종 매개 변수로 전달하십시오.

+0

은 메시지에 필요한 AsyncState입니까? 나는 messagenumber를 찾기 위해 if 쿼리를 만들고 싶다. "반환 값 : <0 \t 오류 (자세한 정보는 msg 매개 변수에서 찾을 수 있습니다.) = 0 \t OK. = 1 \t OK." – mnlfischer

+0

@ManuelFischer 그러면 EndInsertIncident에서 반환 값을 가져와야합니다. 이것은 비동기 상태와는 아무런 관련이 없습니다. 비동기 상태의 목적은 호출자에게 전적으로 관련한 정보를 콜백에 전달하여 콜백이 호출되는 컨텍스트를 알 수 있도록하는 것입니다. –

+0

괜찮아요,하지만 그 작은 misterious, 내가 왜 밖으로 문자열 메시지를 통해 어떤 정보를 얻지 않아, 그게 아니야? – mnlfischer