0

メソッドのいくつかに問題があり、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 = "....";
        }
    }

Callback に WaitHandle を実装するにはどうすればよいですか? この場合、WaitHandle は正しいオプションですか?

4

1 に答える 1

1

AppPool スレッドで WaitHandle を使用して無期限に待機させると、サーバーがすぐに機能しなくなります。

やらないでください。

これを回避するために Web で使用できる代替手段がいくつかあります。

この返信を送信するときに、「処理中」というメッセージをユーザーに表示できます。

その非同期呼び出しで応答ストアの結果を受け取ったら、SignalRなどのフレームワークを使用してユーザーにプッシュできます。

または、結果をセッション変数に保存し、UpdatePanel を使用して更新し、一定間隔でステータスを表示することもできます。

于 2013-02-28T12:41:30.680 に答える