mercredi 2 novembre 2016

a design pattern to replace do while and sleep

I'm using a rest API with two method:

  1. The first one start a job and it return the job id (RunJob).
  2. The second one get me the job termination stats:(GetJobStat

    This is the code that I'm using :

        var id = RunJob();
        Console.WriteLine(string.Format("id {0}",id));
        do
        {
            Thread.Sleep(100);
        } while (GetJobStat(id));
        Console.ReadLine();
    
    

    My question is there any better ways to manager my GetJobStat call than using do while with sleep, I'm searching for a design pattern to optimize my code.

Aucun commentaire:

Enregistrer un commentaire