How to suppress the Window not responding - force quit/wait error message in ubuntu?

Hello,

In my extension I need to add a particular number of segmentation nodes that are ellipsoidal to the scene. After adding I am transforming them to a particular point one by one.

But when the number of segmentation nodes that need to be added to the scene is high ubuntu throws a pop up saying “Application not responding“ with options for Force quit and Wait.

How can I suppress the pop up from coming up? I added:
StateState(vtkMRMLScene::BatchProcessState)

and

EndState(vtkMRMLScene::BatchProcessState)

In the loop where I add segmentation nodes one by one.

Any help will be appreciated.

Thanks in advance.