Hi All
Bellow i display my code Here i have one array i need to send array value one by one to api call post method.It's working fine.
But if array have 100 value means while loop executing my windows application was hanged.So please any one give some idea are solution for handle this.
for(int i=0;i<array.lrength;i++){
sendValue(array[i]);
}
public void sendValue(string tag)
{
string post_data = "tag=";
post_data += tag;
post_data += "&key=test1234";
string uri = localHost:3000/api";
try
{
// create a request
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(uri);
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version11;
request.Method = "POST";
byte[] postBytes = Encoding.ASCII.GetBytes(post_data);
// this is important - make sure you specify type this way
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Flush();
requestStream.Close();
}
catch (Exception ex)
{
Console.WriteLine("..............Exception.......{0}", ex.Message);
}
}
gowthaman8870226416