On Sun, 16 Nov 2008 01:02:47 -0800, Sathyaish <sa*******@gmail.comwrote:
From inside a class library, in a WPF application, I wish to get a
handle to an object, any object, may be the System.Windows.Application
object that supports a method such as DoEvents() by calling which, I
can force the control to yeild to the operating system so that the UI
thread is not blocked, and the dispatcher is not suspended.
Can you please help?
In WPF, just as in the Forms namespace, there is just one way to
accomplish this. WPF has an event dispatcher class, and there's a method
to allow explicit and immediate processing of events currently in the
queue. If you just search MSDN for "WPF" and "event dispatch", it seems
likely you'd find it.
But, as Marc and Mike point out, this sort of programming style is really
not a good idea. One of the most problematic issues is that it introduces
a re-entrancy into a code base that was never designed for re-entrancy to
occur. Much of the time this won't matter, but when it does it will
create bugs that are difficult to find and fix. You're better off just
doing the extra effort to correctly implement time-consuming tasks on a
different thread.
Pete