How to Assign Task Description

In one of comments the following code did not set a task description (shown in vSphere Client in Details column):

LocalizableMessage lm = new LocalizableMessage(); 
lm.setMessage(“Hello World”); 
myTask.getTaskInfo().setDescription(lm);

The problem is in missing key property of the newly created LocalizableMessage: it must be assigned from the task itself.

This is how it’s supposed to be done (Java):

LocalizableMessage lm = new LocalizableMessage();
lm.setKey(myTask.getTaskInfo().getKey());
lm.setMessage(“Hello World”);
myTask.getTaskInfo().setDescription(lm);

This is an example in C# (taskInfo is known value of Vim.TaskInfo type):

LocalizableMessage myDetailMessage = new Vim25Api.LocalizableMessage()
   { key = taskInfo.key, message = "my details" };
connection.Service.SetTaskDescription(taskInfo.task, myDetailMessage);

How to Retrieve Task Info

This is how to retrieve a task info in you have the task MOR:

ObjectContent[] objs =
connection.Service.RetrieveProperties(
   connection.ServiceContent.propertyCollector, new PropertyFilterSpec[]
   {
      new PropertyFilterSpec()
      {
          objectSet = new ObjectSpec[]
             { new ObjectSpec() { obj = taskMOR } },
          propSet = new PropertySpec[]
          {
             new PropertySpec()
             {
                all = false, allSpecified = true,
                type = "Task", pathSet = new String[] { "info" }
             }
          }
      }
   });
TaskInfo result = (TaskInfo)objs[0].propSet[0].val;