I have heavy operation that worked properly (but too long):
_terminationHandler.InsertOrUpdateEmployeeTerminationDetails(TerminationFilters.Current, EmployeeTerminationItems, EmployeeTerminations.Current);
In the Graph that defined this way:
public class MPEmployeeTerminationMaint : PXGraph<MPEmployeeTerminationMaint>
That generates data grid content in these 2 tabs (a few records will be generated):
I was recommended to use
PXLongOperation
:
public async virtual void MPEmployeeTermination_TerminationDate_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
PXLongOperation.StartOperation(this, () =>
{
_terminationHandler.InsertOrUpdateEmployeeTerminationDetails(TerminationFilters.Current, EmployeeTerminationItems, EmployeeTerminations.Current);
});
}
Operation starts:
However it crashes UI (or something happened) after a while:
But no exception is thrown. So there is no exception or another hint what happened.
If you change a editable property, you receive exception:
The "trace" Acumatica page is empty.
If I don't send this
to the PXLongOperation
this problem is resolved:
PXLongOperation.StartOperation(Guid.NewGuid(), () =>
{
_terminationHandler.InsertOrUpdateEmployeeTerminationDetails(TerminationFilters.Current, EmployeeTerminationItems, EmployeeTerminations.Current);
});
however I don't have then indication to the user that long operation happens (obviously: there is no connection between long operation and UI without this
anymore).
What is defined wrongly?
I want to improve user experience and allow him to continue working with the UI when heavy operation happens. If I can achieve this aim in another way - it is also fine. For instance, I can use Guid.NewGuid() instead of this, but then I need to refresh UI manually and moreover the data is not saved.
I will be very grateful to any advice.