Hi!
My application opens another application(RED TITIAN) to convert .pcl files into .pdf files and I must wait for a file, a log file that can be open when the conversion is complete. Until the I want to freez, sleep, pause my application , I tried this :
public void OprireProces(string fis)
{
FileInfo Size = new FileInfo(fis);
if (Size.Length > 629145600)
{
Thread.Sleep(180000);
}
else if (Size.Length > 104857600)
{
Thread.Sleep(120000);
}
fis = fis.Replace(".pcl", ".csv");
Process[] processlist = Process.GetProcessesByName("escapee");
bool p = false;
p = VerificareCSV(fis);
if (!p)
OprireProces(fis);
else
processlist[0].Kill();
}
the function VerificareCSV, just checks if the respective file can be read or not, and returns false or true:
public bool VerificareCSV(string fis)
{
fis = fis.Replace(".pcl", ".csv");
FileStream stream = null;
try
{
stream = File.Open(fis, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException)
{
return false;
}
finally
{
if (stream != null)
stream.Close();
}
return true;
}
the problem occoures when my application has to wait for RED TITAN to convert big files, around 10 or 15 min., I think that Thred.Sleep is the cause, but I can think of another way to pause my application. The crash is ("MyApplication has stop working"...)
Can some one tell me were did I made a mistake ?
Thanks!