当前位置: 首页>>代码示例>>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;未经允许,请勿转载。