IAsyncResult输出字符串始终为空

IAsyncResult输出字符串始终为空

问题描述:

我的字符串消息始终为空,也是我的结果AsyncState ist null。 有人看到错误?IAsyncResult输出字符串始终为空

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); 

我要检查的味精,如果有错误或确定。

+0

那么AsyncState *会*为空 - 你传递'null'作为'BeginInsertIncident'的最后一个参数。 – 2013-02-26 13:58:24

+0

鉴于我们最喜欢的搜索引擎中发现的BeginInsertIncident&EndInsertIncident这个术语的唯一发生就是这个问题,我们该如何猜测发生了什么? -1 – spender 2013-02-26 14:04:40

+0

请参阅编辑 – mnlfischer 2013-02-26 14:19:08

异步状态是您通过的备用object。您正在通过null(作为最终参数);因此AsyncState总是会是null

如果您不想要null,请传入其他内容作为最终参数。

+0

是消息所需的AsyncState?我想做一个if查询来找出messagenumber。 “ ”返回值: mnlfischer 2013-02-26 14:11:49

+0

@ManuelFischer那么你需要从'EndInsertIncident'获取返回值;尽管如此,这与async-state没有任何关系。异步状态的目的是将一些完全特定于调用者的信息*传递给回调函数,以便回调函数可以知道它所调用的上下文。 – 2013-02-26 14:29:37

+0

好吧,但它有点神秘,为什么我没有通过out string msg得到任何信息,不是吗? – mnlfischer 2013-02-26 14:35:45