Taking long to open print dialog

i am trying to print a container but the dialog takes long to open. below is my code under action performed event of a button

ticket = event.source.parent.getComponent(“Container”)
job = system.print.createPrintJob(ticket)
job.print()
window = system.nav.openWindow(‘Home’)
system.nav.closeParentWindow(event)