UI线程的定义是什么?有没有在.NET应用程序只有一个UI线程? [英] What is the definition of a UI thread? Is there only one UI thread in a .NET application?

查看:108
本文介绍了UI线程的定义是什么?有没有在.NET应用程序只有一个UI线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是UI线程?是否有只有一个UI线程在.NET应用程序?

What is a UI thread? Is there only one UI thread in a .NET application?

推荐答案

(简化未来)

一个UI线程是用于创建各种用户界面对象(Winforms中,这意味着控制)单个线程公寓线程。按照惯例和规则,控制可能的只有的从被用来创建它的线程中进行访问;这样做,否则可能并能产生意想不到的效果,从视觉古怪一路崩溃。

A UI thread is a Single Threading Apartment thread that is used to create various user interface objects (in Winforms, this means Controls). By convention and rule, a Control may only be accessed from within the thread that was used to create it; doing otherwise can and will produce unexpected results, from visual oddities all the way to a crash.

除非你明确地创建更多的,只有一个在Windows窗体应用程序的UI线程。当你的可以的创建另一个线程并启动一个消息循环,也有极少数的原因,你会想这样做,和两个不同的UI线程不能对话对方比任何其他更多线程可以与UI线程。

Unless you explicitly create more, there is only one UI thread within a Windows Forms application. While you can create another thread and start a message loop, there are very few reasons why you'd want to do this, and two different UI threads cannot "talk" to each other any more than any other thread can talk to a UI thread.

这篇关于UI线程的定义是什么?有没有在.NET应用程序只有一个UI线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆