code: func Wait(ctx context.Context, ref types.ManagedObjectReference, pc *property.Collector, s progress.Sinker) (*types.TaskInfo, error) {
  	cb := &taskCallback{}
  
  	// Include progress sink if specified
  	if s != nil {
  		cb.ch = s.Sink()
  		defer close(cb.ch)
  	}
  
  	err := property.Wait(ctx, pc, ref, []string{"info"}, cb.fn)
  	if err != nil {
  		return nil, err
  	}
  
  	return cb.info, cb.err
  }
docs: // Wait waits for a task to finish with either success or failure. It does so
  // by waiting for the "info" property of task managed object to change. The
  // function returns when it finds the task in the "success" or "error" state.
  // In the former case, the return value is nil. In the latter case the return
  // value is an instance of this package's Error struct.
  //
  // Any error returned while waiting for property changes causes the function to
  // return immediately and propagate the error.
  //
  // If the progress.Sinker argument is specified, any progress updates for the
  // task are sent here. The completion percentage is passed through directly.
  // The detail for the progress update is set to an empty string. If the task
  // finishes in the error state, the error instance is passed through as well.
  // Note that this error is the same error that is returned by this function.
  //