views:

188

answers:

1

I'm having a WinForms application where I would like to perform some long-running operations, e.g. imagine Explorer copying 2 big files in parallel. For each of those long-running operations I'm starting a separate UI thread (which includes pumping messages/Application.Run/Application.ExitThread) where I create an instance of the IProgressDialog.

I'm wondering - due to the thread affinity of windows - is it legal to package the main form's handle into a HandleRef and pass it as owner/parent of the progress dialog, which is on a different UI thread? I'm not accessing the main window's handle from the secondary UI thread (no cross-thread exceptions in debug mode), only passing it on to the native function.

Thanks.

A: 

Yes, that's fine. Windows allows windows of different threads to have a parent/child relationship.

RichieHindle