Could not assess data from UI of Pyside2?

When I create UI from Pyside2 to get data of blender.
If I use " app.quit()" , I can control UI of Blender but I can not get information when using function “bpy.context.selected_objects”.
If I use " app.exec_()" , UI of Blender is blocked but I can get information when using function “bpy.context.selected_objects”.

How to access data from UI of Pyside2 without blocking UI of Blender?

Thank you?

You’ll have to run it in a separate thread.

I try to use thread below:

class MyThread(QtCore.QThread):

def __init__(self):
    super(MyThread, self).__init__()

def __del__(self):
    self.wait()

def run(self):
    main()

my_thread = MyThread()
my_thread.start()

It run, but blocking UI of PySide.