IAsyncResult输出字符串始终为null

时间:2013-02-26 13:56:56

标签: c# asynchronous callback null

我的字符串消息ist始终为null,我的Result AsyncState也是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好的。 = 1好的。 方法详情:

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,如果有错误或确定。

1 个答案:

答案 0 :(得分:0)

async-state是您传入的备用object。您传入null(作为最终参数);因此,AsyncState始终为null

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