我的一些方法有问题,我认为 WaitHandle 是解决方案。
我通过 API 到 Ticketsystem 创建一个事件。
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";
hajas211ilt3.ILTISAPI api = new hajas211ilt3.ILTISAPI();
api.BeginInsertIncident(username, "", msg_id, "", "", "2857",
"BISS - Software Deployment", "", "", "NOT DETERMINED",
"", "", "", "", "", "", "5 - BAU", "3 - BAU", "",
"Interface", "", "", "", "", "", "",
delegate(IAsyncResult r)
{ InsertIncidentCallback(api, r, username, msg_id); }, null);
}
此方法在 create_Incident 方法中作为回调调用。
private void InsertIncidentCallback(server3.ILTISAPI api, IAsyncResult result,
string username, string msg_id)
{
api.EndInsertIncident(result, out message);
}
我需要 if 中的消息,但我需要安全性,即有消息。所以我必须等待 InsertIncidentCallback 和消息。
在另一种方法中,我问,如果消息正常:
private void checkIncident(string omputer_idn, string swidn_choice,
string swName_choice, string CI_Number,
string windows_user)
{
if (message == null)
{
string responseXML;
api.REMEDY_ReadResponseXML(username, out responseXML, out msg_id);
XDocument doc = XDocument.Parse(responseXML);
inquiryId = (string)doc.Root.Element("inquiry_id");
if (inquiryId == null || inquiryId == "")
{
information_text.Text = ".....";
}
else
{
information_remedyID.Visible = true;
information_remedyID.Text = inquiryId;
create_LanDesk(computer_idn, swidn_choice,
swName_choice, inquiryId);
}
}
else
{
information_text.Visible = true;
information_text.Text = "....";
}
}
如何实现回调的 WaitHandle?在这种情况下,WaitHandle 是正确的选择吗?