Am 08.04.2011 20:30, schrieb Tom Shelton:
> Armin Zingler laid this down on his screen :
>> Am 08.04.2011 05:14, schrieb Jason Keats:
>>> "Armin Zingler" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Hi,
>>>>
>>>> as you don't like long descriptions: How can I avoid or control the
>>>> creation of a MarshalingControl?
>>>
>>> As I don't like long answers:
>>> http://code.google.com/p/retlang/
>>
>> That's what I can expect from my question.
I thank you, though
>> I'm trying to elaborate a bit more:
>> My problem is that I got a dead-lock in my application running
>> two UI-threads independently. That means, I've payed great attention
>> to not creating a dead-lock in my own code. If you look at it, you'd
>> also be surprised that it can happen.
>> To be more specific, the line "New MyForm" does not return.
>> I do not do anything special in it. The window handle of the
>> Form is also not created inside because I do know that it
>> could cause a dead-lock. That's why *I* avoided it. However,
>> *the FW* internally creates a MarshallingControl and it's handle
>> inside "New MyForm". I'm a bit lost how to avoid this.
>
> Armin - I'm having a bit of trouble following what your trying to
> accomplish here... There shouldn't be an issue just creating forms on
> different threads - is there some whay you could create a smallish
> example that demonstrates your problem?
Thanks Tom for asking. Smallish is difficult. But I try to describe:
I wrote a TraceListener. It starts a new thread. The thread creates
a Form to display the output of the TraceListener. The TraceListener
must wait a short moment until the Form has been created:
Thread:
f_Form = New Traceform
FormCreatedEvent.Set
Listener:
FormCreatedEvent.WaitOne
WaitOne must be used carefully. I myself didn't put any blocking code into
"New Traceform", therefore it's ok here. I've put TraceListener+Form into
a Dll and have used it from several projects (successfully).
In my current project, I'm using the library, too. I put Debug.Writeline into
the WndProc of my startup Form. Result: Freeze at start-up. I found out that
the main thread is stuck in
CreateHandle -> WndProc -> Debug.Writeline -> TraceListener -> FormCreatedEvent.WaitOne
I wondered why WaitOne still waits because "New TraceForm" in the other thread
should be done in a millisecond. So, why does "New TraceForm" not return? The
callstack shows:
New TraceForm -> .... -> New MarshalingControl -> MarshalingControl.Creathandle
Conclusion: While the main thread is inside CreateHandle waiting for the
Form in the other thread being created, that thread is also inside
CreateHandle trying to create the MarshalingControl. The FW synchronizes
simultaneous creation of window handles from different threads. That's ok,
and I don't do it myself, but due to that MarshalingControl which is out
of my own scope of responsibility, the dead-lock occurs.
--
Armin