0
ボタンをクリックしてURLにPOSTしようとしています(カメラのトリガーパルスを有効にするため)。ボタンのクリックでトリガパルスを無効にする同様のコードがあります。私が直面している問題は、アクションが完了するのに異常に高い遅延があることです。私はなぜそれが早く完了し、時には大きな時間がかかるのか理解できませんでした。助けてもらえますか?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);
}
}
しばらくアイドル状態になっていると、Webアプリケーションを再起動する必要が生じることがあります。サーバーは2回目以降のリクエストでより迅速に応答しますか? –