I'm doing a module that works with file sharing and in the documentation it asks to wait 20 seconds for the status file xxxxxxxx.sta, however, I'm not sure how to implement this in C #. I was trying something on this line, but it seems to run asynchronously, so I can not get the bool result if the file exists or not at the time I want:
public void ValidarArquivoStatus(int numeroSequencialDoArquivo)
{
seq = numeroSequencialDoArquivo;
aTimer = new Timer(1000);
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = true;
}
private static void OnTimedEvent(Object source, ElapsedEventArgs e)
{
Principal.ValidouArquivoDeStatus = false;
previousTime = e.SignalTime;
//int tempoMaximoTentativaExecucao = Convert.ToInt32(Funcoes.LeParametro(14, "7", false));
int tempoMaximoTentativaExecucao = 20;
if (ExisteArquivoDeStatus(seq))
{
//aTimer.Enabled = false;
Principal.ValidouArquivoDeStatus = true;
aTimer.Enabled = false;
}
nEventsFired++;
if ((nEventsFired == tempoMaximoTentativaExecucao) || (Principal.ValidouArquivoDeStatus == true))
{
aTimer.Enabled = false;
}
}