Refreshing a table during other operation

Hi,
I have a button and a table. On click of this button various database operations are performed and it takes 2 mins to complete the transaction. Meanwhile, few rows are inserted into the table. I have used a timer to refresh the table every 3000 ms. but still, the table is not getting updated since the button operation is performed. How to refresh a table when other operations are performed at the same time ?

Hi @Vignesh_Iyer,
You probably need to use Background Tasks to update the UI while performing long-running tasks (take a look at the example in the manual).

I don’t have all the details, but it seems that you are using a single transaction. So when you refresh the table, another transaction is used, and nothing is changed because the former transaction has not been finished yet.

If that is the case, then you have some alternatives:

  1. Split your transaction (commit records in different transactions), so when you refresh the table the new transaction can return some of the new records (the ones already commited to database)

  2. Implement some sort of logic in your refresh method that can pick return records already processed by your service, but not yet commited.

Hope it helps.

Regards,
Peterson.

1 Like

Hi Peterson,
I have shifted all the long-running tasks to Backgroud tasks as you mentioned. The table on the UI is getting refreshed using a timer. Thanks a ton for helping.