> "The CLR has been unable to transition from COM context 0x1b0f58 to COM
> context 0x1b10c8 for 60 seconds. The thread that owns the destination
[quoted text clipped - 9 lines]
> So, in my C# loop (reading in a bunch of images) - how do I pump windows
> messages so that my application responds?
You don't. Instead, avoid calling STA COM components from non-STA threads.
David
> "The CLR has been unable to transition from COM context 0x1b0f58 to
> COM context 0x1b10c8 for 60 seconds. The thread that owns the
[quoted text clipped - 9 lines]
> So, in my C# loop (reading in a bunch of images) - how do I pump
> windows messages so that my application responds?
The crude way (that lots of people will probably jump on and say "don't do
that") is to call Application.DoEvents every now and then while you're
reading files (e.g. once per file).
The right way is to move your lengthy processing to a worker thread. Use
async delegates, the thread pool, the new BackgroundWorker (2.0) class, or
the System.Threading API directly. Be aware that once you move processing
to a worker thread, you need to marshall all UI access into the correct
thread using Control.{Begin}Invoke. It's not allowed under Winforms 2.0 for
a thread other than the owning thread to touch any GUI compoent. (It was
allowed in 1.1 and before, but there was no guarantee that it would work,
and it's prone to deadlocks. This is a core Windows limitation, not
anything specific to Winforms).
-cd
Mark Ingram - 29 Nov 2006 16:54 GMT
> The crude way (that lots of people will probably jump on and say "don't do
> that") is to call Application.DoEvents every now and then while you're
[quoted text clipped - 11 lines]
>
> -cd
Ahh, DoEvents, that was the hack I was looking for. A thread is
preferable long term, but for now I just want to get rid of the error :)
Thanks,