推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
qsnow6
V2EX  ›  Python

IronPython ui 线程怎么调用?

  •  
  •   qsnow6 · May 18, 2017 · 1781 views
    This topic created in 3422 days ago, the information mentioned may be changed or developed.

    在 IronPython 想把 UI 线程和主线程分开,避免被卡死 但是敲好代码后发现代码在 UI 下不起作用?

    import wpf
    from System.Windows import Application, Window
    from threading import Thread
    import time
    
    class TiebaClientTools(Window):
    
        def __init__(self):
            wpf.LoadComponent(self, 'TiebaClientTools.xaml')
    
    
            
    
        def Button_Click(self, sender, e):
            def set_text(num):
                time.sleep(num)
                self.textbox.Text = "new text"
            t = Thread(target=set_text, args=(3,))
            t.start()
    
    if __name__ == '__main__':
        Application().Run(TiebaClientTools())
    
    
    1 replies  •  2017-05-18 12:45:14 +08:00
    sujin190
        1
    sujin190  
       May 18, 2017
    首先,ui 线程还是在主线程下的,而且我记得操作系统对主线程启动为 ui 线程是有特殊处理的,你这样是没办法把 ui 线程放到其他线程的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1219 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 17:11 · PVG 01:11 · LAX 10:11 · JFK 13:11
    ♥ Do have faith in what you're doing.