I have a strange problem.

I have an aplication which uses plugins, and i try to develop a plugin for
that aplication (dll). The plugin is loaded correctly, but when i try to
open a modal dialog in the called function, the application hangs up (and
the dialog is not shown).
I created a separate thread for the dialog, and i after i start that thread,
i execute a loop to handle the main program's messages. It's working in this
way, BUT, i have to open an other dialog from the shown dialog.. Now comes
the strange part. Sometimes the dialog is shown, but usually is not. Anybody
could help me?