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

  • Thread starter Thread starter forest demon
  • Start date Start date
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.
 
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.
 
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 -
 
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 -
 
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 -
 
Back
Top