public ResponseService Cancel(List <Field> Fields) { if (!IsConfigured) { throw new Exception(); } string[] credentials = { Url, User, Password, EncryptedKey }; int[] config = { Group, Chain, Merchant, POS, Cashier }; var _DT = new Class_DT(); var task = Task.Run(() => { return(_DT.Send_Request("Reversa", credentials, Fields, config)); }); try { var success = task.Wait(45000); if (success) { var x = _DT.GetFieldsFromXml(task.Result.response); var responseService = new ResponseService(); if (x.field.Count > 0) { responseService.Success = true; responseService.XML = x.xmlResponse; foreach (var item in x.field) { switch (item.Name) { case "CODIGORESPUESTA": responseService.ResponseCode = int.Parse(item.Value.ToString()); break; } } responseService.Fields = x.field; return(responseService); } } } catch (AggregateException ex) { throw ex.InnerException; } return(new ResponseService()); }