Each time CurlFile() is called it creates a new object from the ProcessObject class. The ProcessObject object starts the new Process. I want the Process.Exit event in each object to trigger the static event handler in the parent class, but it doesn't seem to be working for some reason.
class Curl
{
StringContainer oStrings = new StringContainer();
private static int _counter = 0;
private string _curl;
public Curl()
{
//oStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
_curl = oStrings.Curl;
}
public void CurlFile(string _arg)
{
ProcessObject oProcessObject = new ProcessObject(_arg, _curl);
}
private static void oProcess_Exited(object sender, EventArgs e)
{
_counter++;
if (_counter == 1000)
{
MessageBox.Show("here");
}
}
private class ProcessObject
{
ProcessStartInfo oStartInfo = new ProcessStartInfo();
Process oProcess = new Process();
public ProcessObject(string _arg, string _curl)
{
oStartInfo.FileName = _curl;
oStartInfo.Arguments = _arg;
oProcess.EnableRaisingEvents = true;
oProcess.Exited += new EventHandler(oProcess_Exited);
oProcess = Process.Start(oStartInfo);
}
}
}