thread , form

  • Thread starter Thread starter Ryan Liu
  • Start date Start date
R

Ryan Liu

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
 
Ryan Liu said:
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
 
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:[email protected]...
 
Hi,

Ryan Liu said:
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
 

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

Back
Top