public decimal ValidateVoidVoucher(string ticketNumber, int userNo, ref int?nResult) { decimal dAmount = 0; try { // is tis printed ticket if (VoucherHelper.IsTISPrintedTicketPrefix(ticketNumber)) { // if the tis printed ticket available in local db bool isTISTicketAvailable = VoucherHelper.IsTISPrintedTicket(ticketNumber); if (!isTISTicketAvailable) { // wait worst case 10 secs to get the response from TIS int count = 10; string message = "Waiting for receiving data from TIS..."; WPFExtensions.ShowAsyncDialog(null, message, null, 1, count, (o) => { IAsyncProgress2 o2 = o as IAsyncProgress2; // failure case - hit the tis communication interface and get the ticket try { o2.UpdateStatusProgress(5, message); VoucherHelper.SendTISRedeemTicketQuery(ticketNumber, userNo); o2.UpdateStatusProgress(10, message); } catch (Exception ex) { ExceptionManager.Publish(ex); } }); } } // Success/failure case - ok proceed with voiding foreach (var obj in this.ValidateVoidVoucher(ticketNumber, ref nResult)) { dAmount = Convert.ToDecimal(obj.iAmount) / 100; } } catch (Exception ex) { ExceptionManager.Publish(ex); } return(dAmount); }