Hello, I am trying to POST to a URL on the click of a button (to enable trigger pulse of the camera). I have a similar code to disable trigger pulse on the click of a button. The problem i face is that there is an abnormally high delay for the action to get completed. I could not figure out why it completes early sometimes and takes large time sometimes. Can someone help ?
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);
}
}