當前位置: 首頁>>代碼示例>>Python>>正文


Python win32event.MsgWaitForMultipleObjects方法代碼示例

本文整理匯總了Python中win32event.MsgWaitForMultipleObjects方法的典型用法代碼示例。如果您正苦於以下問題:Python win32event.MsgWaitForMultipleObjects方法的具體用法?Python win32event.MsgWaitForMultipleObjects怎麽用?Python win32event.MsgWaitForMultipleObjects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32event的用法示例。


在下文中一共展示了win32event.MsgWaitForMultipleObjects方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: WaitWhileProcessingMessages

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import MsgWaitForMultipleObjects [as 別名]
def WaitWhileProcessingMessages(event, timeout = 2):
    start = time.clock()
    while True:
        # Wake 4 times a second - we can't just specify the
        # full timeout here, as then it would reset for every
        # message we process.
        rc = win32event.MsgWaitForMultipleObjects( (event,), 0,
                                250,
                                win32event.QS_ALLEVENTS)
        if rc == win32event.WAIT_OBJECT_0:
            # event signalled - stop now!
            return True
        if (time.clock() - start) > timeout:
            # Timeout expired.
            return False
        # must be a message.
        pythoncom.PumpWaitingMessages() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:eventsApartmentThreaded.py

示例2: test

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import MsgWaitForMultipleObjects [as 別名]
def test(fn):
    print "The main thread is %d" % (win32api.GetCurrentThreadId())
    GIT    = CreateGIT()
    interp = win32com.client.Dispatch("Python.Interpreter")
    cookie = GIT.RegisterInterfaceInGlobal(interp._oleobj_, pythoncom.IID_IDispatch)
    
    events = fn(4, cookie)
    numFinished = 0
    while 1:
        try:
            rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
            if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                numFinished = numFinished + 1
                if numFinished >= len(events):
                    break
            elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                # This is critical - whole apartment model demo will hang.
                pythoncom.PumpWaitingMessages()
            else: # Timeout
                print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
        except KeyboardInterrupt:
            break
    GIT.RevokeInterfaceFromGlobal(cookie)
    del interp
    del GIT 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,代碼來源:testGIT.py

示例3: demo

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import MsgWaitForMultipleObjects [as 別名]
def demo (delay=1000, stop=10):
    g = glork(delay, stop)
    # Timers are message based - so we need
    # To run a message loop while waiting for our timers
    # to expire.
    start_time = time.time()
    while 1:
        # We can't simply give a timeout of 30 seconds, as
        # we may continouusly be recieving other input messages,
        # and therefore never expire.
        rc = win32event.MsgWaitForMultipleObjects(
                (g.event,), # list of objects
                0, # wait all
                500,  # timeout
                win32event.QS_ALLEVENTS, # type of input
                )
        if rc == win32event.WAIT_OBJECT_0:
            # Event signalled.
            break
        elif rc == win32event.WAIT_OBJECT_0+1:
            # Message waiting.
            if win32gui.PumpWaitingMessages():
                raise RuntimeError("We got an unexpected WM_QUIT message!")
        else:
            # This wait timed-out.
            if time.time()-start_time > 30:
                raise RuntimeError("We timed out waiting for the timers to expire!") 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:29,代碼來源:timer_demo.py

示例4: testMsgWaitForMultipleObjects

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import MsgWaitForMultipleObjects [as 別名]
def testMsgWaitForMultipleObjects(self):
        # this function used to segfault when called with an empty list
        res = win32event.MsgWaitForMultipleObjects([], 0, 0, 0)
        self.assertEquals(res, win32event.WAIT_TIMEOUT) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:test_win32event.py

示例5: testMsgWaitForMultipleObjects2

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import MsgWaitForMultipleObjects [as 別名]
def testMsgWaitForMultipleObjects2(self):
        # test with non-empty list
        event = win32event.CreateEvent(None, 0, 0, None)
        res = win32event.MsgWaitForMultipleObjects([event], 0, 0, 0)
        self.assertEquals(res, win32event.WAIT_TIMEOUT) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_win32event.py

示例6: doWaitForMultipleEvents

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import MsgWaitForMultipleObjects [as 別名]
def doWaitForMultipleEvents(self, timeout):
        log.msg(channel='system', event='iteration', reactor=self)
        if timeout is None:
            #timeout = INFINITE
            timeout = 100
        else:
            timeout = int(timeout * 1000)

        if not (self._events or self._writes):
            # sleep so we don't suck up CPU time
            time.sleep(timeout / 1000.0)
            return

        canDoMoreWrites = 0
        for fd in self._writes.keys():
            if log.callWithLogger(fd, self._runWrite, fd):
                canDoMoreWrites = 1

        if canDoMoreWrites:
            timeout = 0

        handles = self._events.keys() or [self.dummyEvent]
        val = MsgWaitForMultipleObjects(handles, 0, timeout, QS_ALLINPUT | QS_ALLEVENTS)
        if val == WAIT_TIMEOUT:
            return
        elif val == WAIT_OBJECT_0 + len(handles):
            exit = win32gui.PumpWaitingMessages()
            if exit:
                self.callLater(0, self.stop)
                return
        elif val >= WAIT_OBJECT_0 and val < WAIT_OBJECT_0 + len(handles):
            fd, action = self._events[handles[val - WAIT_OBJECT_0]]
            log.callWithLogger(fd, self._runAction, action, fd) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:35,代碼來源:win32eventreactor.py


注:本文中的win32event.MsgWaitForMultipleObjects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。