.NET 2.0
Some code is running in the context of a .NET console app. It happens to be its main thread, obviously there is no message pump on this thread.
This thread needs to create a form. So it needs a UI thread.
Once it has a form it can marshal the calls to that thread via form.invoke or via the synchronization context which was current when the form was created.
So, I create a worker thread; and within this call application.run.
Problem is creating the form on that thread.
If it was only ever one form I could create it before calling application.run; but there are many - and multiple - forms that I need to create.
I only know which ones from the worker thread; thus I need either a sync context or a form in order to be able to marshal execution to that thread. But of course the sync context doesn't exisit until a form is created.
Any suggestions?
Hack is the create a dummy form and marshal to this. But surely there is a better way.
Some code is running in the context of a .NET console app. It happens to be its main thread, obviously there is no message pump on this thread.
This thread needs to create a form. So it needs a UI thread.
Once it has a form it can marshal the calls to that thread via form.invoke or via the synchronization context which was current when the form was created.
So, I create a worker thread; and within this call application.run.
Problem is creating the form on that thread.
If it was only ever one form I could create it before calling application.run; but there are many - and multiple - forms that I need to create.
I only know which ones from the worker thread; thus I need either a sync context or a form in order to be able to marshal execution to that thread. But of course the sync context doesn't exisit until a form is created.
Any suggestions?
Hack is the create a dummy form and marshal to this. But surely there is a better way.
Comment