Issues with multiple GUI threads (ó#, .NET 1.1)

  • Thread starter Alexei Adadurov
  • Start date
A

Alexei Adadurov

Hi!

I already posted this message in microsoft.public.dotnet.framework, but I
see almost no reaction, so I decided to re-post it to others newsgroups,
too. I just wonder if anybody has faced this problem before and could help
to troubleshoot it. Following is my original message.

Thanks for your attention.
Alexei Adadurov
(alexei.adadurov at super-lab dot ru)

---------------------------------------------------------------------------------------
Hello!

I am writing a desktop application that uses multiple GUI threads to
interact with the user.
Secondary GUI thread creates a main form for this thread, having
application's main form as its parent and calls
System.Windows.Forms.Application.Run() with this newly created form.
The problem is that, under certain conditions (described below) secondary
GUI thread strangely crashes after it has exited the 'threadstart' function.
The crash is 'Unhandled access violation exception' (0xc000000a) in
ntdll.dll with the following call stack:

ntdll.dll!_RtlFreeThreadActivationContextStack@0() + 0x1eda4
kernel32.dll!_ExitThread@4() + 0x39
kernel32.dll!_BaseThreadStart@8() + 0x3d


My environment is .NET 1.1, Microsoft Windows XP SP2.
And yes, it crashes on another machines, too.

Condition for crash is that thread crashes only after I create and display a
modal dialog box (another custom form), heaving main form for GUI thread #2
as Parent. This dialog box is used to display messages to the user instead
of System.Windows.Forms.MessageBox (it has enhanced functionality like
"Don't show this anymore" checkbox and timeout timer allowing it to be
dismissed if user haven't clicked any buttons. When I switch back to
System.Windows.Forms.MessageBox everything is fine.

As this issue occurs in a big solution, I created new simple little
CrashTest project to simulate this behavior and isolate my problem, but so
far I haven't succeeded.

Does anyone know what could cause this behaviour?

Best regards,
Alexei N. Adadurov

(alexei.adadurov at super-lab dot ru)
 
A

Asela Gunawardena

Adding controls to the form that is executed by the main GUI thread is
through another thread is not allowed, so try displaying the dialog using
the main controls invoke mehtod.
 
S

Stoitcho Goutsev \(100\)

Asela,

Adding controls created in one thread to parent created in another thread is
not allowed and exception is thrown right away. In such cases the call needs
to be marshaled to the UI thread and the child control (handle) created
there.

I don't think though that Alexei problem is this. Without test application
there will be only quesses
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top