By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,989 Members | 1,475 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,989 IT Pros & Developers. It's quick & easy.

thread , form

P: n/a
I have an thread keep running at the backgroud, if it receive an message
from network, it will pop up an chat form and show the message in the chat
form.

Since this chat form in not pop up by main thread associated with main form,
to make this chat form visible, I use Application.Run(chatForm) to make it
work.

But seems then this will block the main application and the backend thread,
and no other message can be received.

Can someone tell me how to solve this?

Thanks a lot!
Ryan
May 17 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Ryan Liu" <ad********@online.sh.cn> wrote in message
news:On**************@TK2MSFTNGP02.phx.gbl...
I have an thread keep running at the backgroud, if it receive an message
from network, it will pop up an chat form and show the message in the chat
form.

Since this chat form in not pop up by main thread associated with main
form,
to make this chat form visible, I use Application.Run(chatForm) to make it
work.

But seems then this will block the main application and the backend
thread,
and no other message can be received.

Can someone tell me how to solve this?

Thanks a lot!
Ryan


Why not have the main thread popup the form - you can get the notification
on to the main thread by using Control.BeginInvoke

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
May 17 '06 #2

P: n/a
I tried 3 ways:

run the Application.Run(chatForm) in a new thread,
or in a chatDelegate.BeginInvoke(...)
or in applicationMainForm.BeginInvoke(chatDelegate, new object[]{chatForm})

the I can see the chatFrom in tastbar, I just can not activate it and see
it. Or even seems it run into a deal loop.

What are the best way to open another form by an backend thread?

Thanks!
Ryan

"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> дʼ news:e8**************@TK2MSFTNGP02.phx.gbl...
"Ryan Liu" <ad********@online.sh.cn> wrote in message
news:On**************@TK2MSFTNGP02.phx.gbl...
I have an thread keep running at the backgroud, if it receive an message
from network, it will pop up an chat form and show the message in the chat form.

Since this chat form in not pop up by main thread associated with main
form,
to make this chat form visible, I use Application.Run(chatForm) to make it work.

But seems then this will block the main application and the backend
thread,
and no other message can be received.

Can someone tell me how to solve this?

Thanks a lot!
Ryan


Why not have the main thread popup the form - you can get the notification
on to the main thread by using Control.BeginInvoke

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

May 17 '06 #3

P: n/a
Hi,

"Ryan Liu" <ad********@online.sh.cn> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
I tried 3 ways:

run the Application.Run(chatForm) in a new thread,
Wrong way
or in a chatDelegate.BeginInvoke(...)
where is chatDelegate declared ?
or in applicationMainForm.BeginInvoke(chatDelegate, new
object[]{chatForm})
is applicationMainForm the top most window? if by any change
applicationMainForm show a new form using ShowDialog you could get in
problems.

What are the best way to open another form by an backend thread?


You have to send a message to the UI , then it will create a new dialog.

IT depend of what form is the topmost in your app.

Will it be the same form ever?

if not defining an interface could be a solution

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 17 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.