This document describes the PX1046 diagnostic.
| Code | Short Description | Type | Code Fix |
|---|---|---|---|
| PX1046 | Long-running operations cannot be started within event handlers. | Error | Unavailable |
Long-running operations cannot be started within event handlers.
To fix the issue, you remove the invocation of the long-running operation and rework the related business logic.
public class BinExtension : PXGraphExtension<INSiteMaint>
{
public void INLocation_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
{
if (e.TranStatus != PXTranStatus.Completed) return;
try
{
PXLongOperation.StartOperation(this, delegate () // The PX1046 error is displayed for this line.
{
//export records
});
}
catch (Exception ex)
{
PXTrace.WriteError($"INLocation_RowPersisted - Failed. {ex}");
}
}
}