ServerTask timeout

Hi,

We use many server tasks, as shown below.

ServerTask deleteAlarmServerTask = alarmDefinitionFolder.RemoveAlarmDefinition(alarmDefinitionFolder.RemoveAlarmDefinition().ItemSelectionValues.Where(k => k.Key == name).Select(k => k.Value).Single());
                while (deleteAlarmServerTask.State != StateEnum.Error && deleteAlarmServerTask.State != StateEnum.Success)
                {
                    System.Threading.Thread.Sleep(100);
                    deleteAlarmServerTask.UpdateState();
                }
                Console.WriteLine("Alarm remove task: " + deleteAlarmServerTask.State);
                if (deleteAlarmServerTask.State == StateEnum.Error)
                {
                    Console.WriteLine("Alarm remove error: " + deleteAlarmServerTask.ErrorText);
 
                }

Sometimes the server task stays in while and never comes out. Can we have a custom timeout?

Thanks,

Vega

No, there is no custom timeout that you can set on this. I am in doubt if this answer is what you seek or the answer only triggers new questions. Let us know.

Some times the task never completes ( no success or error) , stays in while for ever

Do you have a question to this observation?

Yes, why does this happen? The task should return success or an error. We are using updatetask to get the latest task status

while (deleteAlarmServerTask.State != StateEnum.Error && deleteAlarmServerTask.State != StateEnum.Success)
                {
                    System.Threading.Thread.Sleep(100);
                    deleteAlarmServerTask.UpdateState();
                }

Eg: when this does not return or exit while, the rest below code never executes and whole later process feels hang

What is the State? When it is not Error or Success, what is it when you experience this issue?

Is the issue easy for you to reproduce? If yes, please let me know what you do to reproduce?

If not easy to reproduce maybe you can log the value so that you can answer my question next time you see the issue again. Maybe introduce a time-out where you log the value and break the loop.