VMware {code} Community
dblock
Enthusiast
Enthusiast

How can I timeout on wix job wait or terminate the job on a timer safely?

This question has been asked several months before, so hopefuly the technology evolved

I had someone pull a cable from the ESX server on me during a process that restores a snapshot. I ended up with a client in an infinite IJob Wait. What's the proper way to time all calls out?

  1. Some way to have a non blocking wait with a very long timeout via VIX API? (I am using C# / VixCOM)

    I am doing this:


    private static void InternalWait(IJob job, int timeoutInSeconds)
    {
    if (timeoutInSeconds == 0)
    {
    throw new ArgumentOutOfRangeException("timeoutInSeconds");
    }
    // active wait for the job to finish
    bool isComplete = false;
    while (!isComplete && timeoutInSeconds > 0)
    {
    Check(job.CheckCompletion(out isComplete));
    if (isComplete) break;
    Thread.Sleep(1000);
    timeoutInSeconds--;
    }


    if (timeoutInSeconds == 0)
    {
    throw new TimeoutException();
    }
    }

  2. Manual timer that aborts the thread? I am worried about the consequences and being able to continue or maybe even retry operation.

  3. Something else?

Thx

dB.

0 Kudos
0 Replies