Mcmullan, Andy (Andrew) [mailto:[EMAIL PROTECTED]] wrote:
> What I'm really interested in is that regardless of whether > MS should have put the check into the .NET GUI libraries or > not, the fact is that they didn't. Well... beyond debugging, why would you want that check to even take place? Even though the performance cost is not *that* bad, it is still an unecessary hit in a release build. I would be willing to venture a guess that in a debug build of the framework, Microsoft very well have such checks in place. > And if omissions like this > could be rectified 'after-the-event', without access to the > library source code, by using AOP, that would be a great > advert for AOP and I'd definitely be interested in looking at > AOP further. They sure could. I'm no AOP officianado, so perhaps John Lam can hop in here and correct any mistakes I make in describing this, but basically you would weave an aspect with a point-cut of before all methods of all classes that derive from System.WinForms.Control (except the four magic methods of course). The aspect could then verify that the callers thread is that of the thread the control was created on and output a trace warning or perhaps even raise an exception. Also remember, technically if a Control subclass is defined it have could have methods that don't interact with thread affine resources and therefore that the method is safe to call from any thread. The only way to know which methods are safe for cross thread calls is to read the documentation for that specific control. When in doubt though, always BeginInvoke. Later, Drew .NET MVP You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
