0

ボタンをクリックしてURLにPOSTしようとしています(カメラのトリガーパルスを有効にするため)。ボタンのクリックでトリガーパルスを無効にする同様のコードがあります。私が直面している問題は、アクションが完了するまでに異常に長い遅延があることです。時には早く完了し、時には非常に時間がかかる理由がわかりませんでした。誰かが助けることができますか?

private void button2_Click_1(object sender, EventArgs e)
{
    try
    {
        string requestmethod = "POST";
        string postData = "";
        byte[] byteArray = Encoding.UTF8.GetBytes(postData);
        string URL = "http://192.168.0.42/entrig.cgi";
        string contenttype = "application/x-www-form-urlencoded";
        request = null;
        request = (HttpWebRequest)WebRequest.Create(URL);
        Stream dataStream;
        ((HttpWebRequest)request).KeepAlive = false;
        request.Method = requestmethod;
        request.ContentType = contenttype;
        request.ContentLength = byteArray.Length;
        dataStream = request.GetRequestStream();
        dataStream.Write(byteArray, 0, byteArray.Length);
        dataStream.Close();
        MessageBox.Show("Started Trigger");
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.StackTrace);
    }
}
4

1 に答える 1

0

サーバーが一貫していると仮定する理由はありません。(たとえば、 Fiddlerを使用して)ワイヤーではないものを監視して、速度が低下している場所を確認してください。

于 2009-04-20T08:05:54.060 に答える