Ian Griffiths on UI Thread
The following message was one of Ian Griffiths's posts on discuss.develop.com.
Alois Reisinger wrote:
> Once again some ui thread question.
> Does all the WinForms have to be on the same thread? (i think no).
No - each top level form is allowed to be on its own thread. While people often use the term "The UI thread" as a convenient shorthand, it's slightly misleading, as a Windows Forms application can in fact have several UI threads. (Although in practice a lot of Windows Forms applications only use one thread as a UI thread. In these cases, it makes perfect sense to refer to "the UI thread.")
Note that it's only with top-level windows that you can do this. Everything inside a particular top-level window has to live on the same thread as that top-level window.
Which leads us onto your next question:
> Could there be a problem, if i have a newly created form that
> should be inserted as a child into a mdi parent if they (parent
> and child) were created on different threads?
Yes, that would be a problem.
Here's why. When you add a form as an MDI child of another form, you are effectively doing two things: you are adding the child to the parent's MdiChildren collection, and you are also setting the child's MdiParent property. Doing one of these implicitly does the other for you. If you write this:
child.MdiParent = parent;
then this has the implicit side effect of adding the child to the parent's MdiChildren. Or if you do this:
parent.MdiChildren.Add(child);
then that has the implicit side effect of setting the child's MdiParent property to refer to the parent.
If these two forms have different UI threads, then whichever thread you choose to set up the parent/child association on, it'll be the wrong thread for one or other of them.
And the same problem applies for normal non-MDI parenting too. (Both for Forms and for any other control. And yes, you can nest a form inside another form without resorting to MDI.)
2 Comments:
louis vuitton outlet, ugg boots, ray ban sunglasses, oakley sunglasses, louis vuitton outlet, longchamp pas cher, prada outlet, polo ralph lauren outlet, nike outlet, chanel handbags, louboutin outlet, longchamp outlet, louis vuitton, nike air max, cheap oakley sunglasses, longchamp outlet, jordan shoes, louis vuitton, nike free, tiffany and co, tory burch outlet, prada handbags, replica watches, nike roshe run, longchamp, louboutin, air max, ralph lauren pas cher, christian louboutin outlet, replica watches, louis vuitton, nike air max, kate spade outlet, louboutin pas cher, nike free, oakley sunglasses, sac longchamp, oakley sunglasses, polo ralph lauren outlet, louboutin shoes, uggs on sale, ray ban sunglasses, ray ban sunglasses, burberry, gucci outlet, oakley sunglasses, tiffany jewelry, ugg boots, air jordan pas cher, michael kors
montre pas cher, moncler outlet, moncler, karen millen, moncler, supra shoes, ugg pas cher, wedding dresses, swarovski, moncler, sac louis vuitton pas cher, doudoune canada goose, moncler, louis vuitton, pandora charms, canada goose, ugg,uggs,uggs canada, swarovski crystal, marc jacobs, hollister, moncler, toms shoes, louis vuitton, ugg boots uk, louis vuitton, canada goose uk, coach outlet, louis vuitton, moncler, canada goose, pandora charms, links of london, moncler, canada goose, canada goose outlet, pandora jewelry, juicy couture outlet, canada goose, thomas sabo, juicy couture outlet, pandora jewelry, bottes ugg, canada goose outlet, ugg,ugg australia,ugg italia, replica watches
Post a Comment
<< Home