Okay basically
/// <summary>
/// Sends the process.
/// </summary>
/// <param name="MD5">The M d5.</param>
/// <param name="procName">Name of the proc.</param>
/// <param name="procLoc">The proc loc.</param>
public void SendProcess(string MD5, string procName, string procLoc)
{
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create("http://localhost/EDAC//SubmitProc.php ");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "MD5=" + MD5 + "&procName=" + procName + "&procLoc=" + procLoc + "&userID=" + _userID;
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
}
This function is called in a loop
Process[] currentProcess = Process.GetProcesses();
foreach (var process in currentProcess)
{
var isContained = false;
foreach (var heldProcess in _processlist)
{
if (heldProcess.Id == process.Id)
{
isContained = true;
}
}
if (!(isContained))
{
try
{
_processLocs.Add(process.MainModule.FileName);
_processlist.Add(process);
_tw.WriteLine(process.ProcessName);
_tw.WriteLine(process.MainModule.FileName);
var md5 = GetMD5HashFromFile(process.MainModule.FileName);
_tw.WriteLine(md5);
SendProcess(md5, process.ProcessName, process.MainModule.FileName);
}
catch (Win32Exception ex)
{
}
}
}
Basically this method is fine on my local host just not on web server, now this method is obviously not idle considering when program first loads you get about 30 connection requests and messages sent within half a second, it locks up basically, probably due to not getting a connection.
So whats the right way of doing this? Ive been looking for a way to get a loop going that waits until server is ready to take more data or is it possibly sending all of the objects and handling that into variables for insert php side