How can I make a Dialog modal in a threaded application?

F

forest demon

i've seen previous posts somewhat related to this, so i apologize if
this is redundant.

I have a main form with separate threads. When showing a dialog like
<dialog>.ShowDialog(), it functions as a non-modal instead of modal.

any help is appreciated, thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

The reason this is happening is that you are most likely not running
message loops in those separate threads.

Why are you showing dialogs and using user interface controls in
separate threads anyways? Not that it's not possible, but for the vast
majority of situations, it's just not necessary.
 
F

forest demon

we do need a form/dialog for one of the threads and for it to be
modal. so, message loops are the answer? can you giude or point me
to an example? thanks...


The reason this is happening is that you are most likely not running
message loops in those separate threads.

Why are you showing dialogs and using user interface controls in
separate threads anyways? Not that it's not possible, but for the vast
majority of situations, it's just not necessary.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




i've seen previous posts somewhat related to this, so i apologize if
this is redundant.
I have a main form with separate threads. When showing a dialog like
<dialog>.ShowDialog(), it functions as a non-modal instead of modal.
any help is appreciated, thanks.- Hide quoted text -

- Show quoted text -
 
N

Nicholas Paldino [.NET/C# MVP]

Forest,

Ok, so why doesn't the worker thread call Invoke on a control on the
main UI thread, and then have that method passed to Invoke handle showing
the modal dialog?

Something tells me that you need to do a lot of work to make sure that
your app is performing multi threading and UI operations correctly. You
need to sort those issues out first.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

forest demon said:
we do need a form/dialog for one of the threads and for it to be
modal. so, message loops are the answer? can you giude or point me
to an example? thanks...


The reason this is happening is that you are most likely not running
message loops in those separate threads.

Why are you showing dialogs and using user interface controls in
separate threads anyways? Not that it's not possible, but for the vast
majority of situations, it's just not necessary.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




i've seen previous posts somewhat related to this, so i apologize if
this is redundant.
I have a main form with separate threads. When showing a dialog like
<dialog>.ShowDialog(), it functions as a non-modal instead of modal.
any help is appreciated, thanks.- Hide quoted text -

- Show quoted text -
 
F

forest demon

thanks for the reply Nicholas .


Forest,

Ok, so why doesn't the worker thread call Invoke on a control on the
main UI thread, and then have that method passed to Invoke handle showing
the modal dialog?

Something tells me that you need to do a lot of work to make sure that
your app is performing multi threading and UI operations correctly. You
need to sort those issues out first.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




we do need a form/dialog for one of the threads and for it to be
modal. so, message loops are the answer? can you giude or point me
to an example? thanks...
The reason this is happening is that you are most likely not running
message loops in those separate threads.
Why are you showing dialogs and using user interface controls in
separate threads anyways? Not that it's not possible, but for the vast
majority of situations, it's just not necessary.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

i've seen previous posts somewhat related to this, so i apologize if
this is redundant.
I have a main form with separate threads. When showing a dialog like
<dialog>.ShowDialog(), it functions as a non-modal instead of modal.
any help is appreciated, thanks.- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
 

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