VMware {code} Community
Jeff3
Contributor
Contributor

Task Race

Thanks for your help.

I'm using the vSphere API to connect to an ESXi host (3.5, 4.0, 4.1) and power-off a vm and then unregister it.

Sometimes I get an error during the unregister saying the vm can't be unregistered while it is powered on.

After executing the PowerOffVm_Task, I wait until TaskInfo.status == success before running the UnregisterVM method. It seems that TaskInfo.status is being set to success before the VirtualMachinePowerState is being set to poweredOff?

Is this a known issue, or am I doing something wrong? I've been adding a sleep interval between successful power-off and unregistering, but it still crops up sporadically, and don't want to be unnecessarily slowing the application down.

0 Kudos
0 Replies