Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
``performSelectorOnMainThread_withObject_waitUntilDone_``.
* ``pyobjc_performSelectorOnMainThread_withObject_waitUntilDone_modes_``
This is the safe alternative for
``performSelectorOnMainThread_withObject_waitUntilDone_modes_``.
Enhanced methods
---------------The stock methods are quite useful, but at times it is usefull to get the
result back from the other thread. The methods below will call the selector
on another thread and will return the result from that call in the current
thread. If the call on the "other" thread raises an exception this exception
will be reraised in the current thread.
Note: these methods are synchronous, that is, they block the current thread
until the call on the "other" thread is done.
As an example:
.. sourcecode:: python
:linenos:
class MyClass (NSObject):
def divideByZero_(self, arg):
return arg/0
def doit(self):
try:
result = self.performSelectorOnMainThread_withObject_(
'divideByZero:', 55)
print result
except:
print "Division failed"
The available methods are:
* ``pyobjc_performSelector_onThread_withObject_(selector, thread, arg)``
(Introduced in Mac OS X 10.5)
* ``pyobjc_performSelector_onThread_withObject_modes_(selector, thread, arg, mod
es)``
(Introduced in Mac OS X 10.5)
* ``pyobjc_performSelectorOnMainThread_withObject_(selector, arg)``
* ``pyobjc_performSelectorOnMainThread_withObject_modes_(selector, arg, modes)``