def someLongWorkingFunction(): print "\tsomeLongWorkingFunction starts in worker thread" i=0 while i<10: time.sleep(2) workerthread.executeInGUIThread( lambda: notifyGUIThread("Processing:%s"%i) ) print "\tsomeLongWorkingFunction: Doing some long work." if i==5: print "\tsomeLongWorkingFunction: i=5. Will notify GUI" workerthread.executeInGUIThread( lambda: notifyGUIThread("We are halfway to the end.") ) i+=1 #END while i<10: print "\tsomeLongWorkingFunction finished processing" notifyOnProcessFinishInGUIThread("long processing: finished")
def someLongWorkingFunctionDecoratedForWorkerThread(self): print "\tsomeLongWorkingFunction starts in worker thread" i=0 while i<5: time.sleep(2) workerthread.executeInGUIThread( lambda: self.notifyGUIThread("Processing:%s"%i) ) print "\tsomeLongWorkingFunction: Doing some long work." if i==3: print "\tsomeLongWorkingFunction: i=3. Will notify GUI" workerthread.executeInGUIThread( lambda: self.notifyGUIThread("We are halfway to the end.") ) i+=1 #END while i<10: print "\tsomeLongWorkingFunction finished processing" self.notifyOnProcessFinishInGUIThread(self, "long processing: finished")
def someLongWorkingFunctionDecoratedForWorkerThread(self, keywordParameter1 = "Default", keywordParameter2= "Default"): print "\tsomeLongWorkingFunction starts in worker thread" print "Keyword parameter1 = %s"%keywordParameter1 print "Keyword parameter2 = %s"%keywordParameter2 i=0 while i<5: time.sleep(2) workerthread.executeInGUIThread( lambda: self.notifyGUIThread("Processing:%s"%i) ) print "\tsomeLongWorkingFunction: Doing some long work." if i==3: print "\tsomeLongWorkingFunction: i=3. Will notify GUI" workerthread.executeInGUIThread( lambda: self.notifyGUIThread("We are halfway to the end.") ) i+=1 #END while i<10: print "\tsomeLongWorkingFunction finished processing" self.notifyOnProcessFinishInGUIThread(self, message="long processing: finished")