Component calling a form

  • Thread starter Thread starter Mike Hildner
  • Start date Start date
M

Mike Hildner

I've created a class library and a component. The component just waits until
a UDP message arrives. What I'd like to do is when I get a message is show a
form that has the data that UdpClient.Receive returns.

So I created a Windows form, with a single text box, in the class library.
If I attempt to show the form with Form.Show() my application becomes "Not
Responding". If I start a thread to show the form, the form just flashes
briefly. If I use Form.ShowDialog() things seem to work ok, except that only
one form at a time will show if there are several messages. Closing the form
then brings up the next message.

I assume I'm doing something wrong by trying to show a form from a
component, but don't really know. Can anyone suggest how to do this
properly?

Thanks,
Mike
 
Well, for now, I'm getting around this by creating a new thread, then doing
Form.ShowDialog and it seems to be ok. Still seems like I'm missing
something :(
 
I assume I'm doing something wrong by trying to show a form from a
component, but don't really know. Can anyone suggest how to do this
properly?

It a poor design Mike. You can do it but you should really be raising
an event and handling that in some "actual" UI.

If you dont like that suggest and want to do it that way then as far
as im aware there is no *technical* reason why you cant. If forms are
just flashing, maybe their going out of scope/being disposed, or
perhaps they are getting trapped behind the main UI.

I would say try setting form.topmost = true but my first sentence is
my real advice.

hth
Richard
 
It a poor design Mike.

Glad to hear that :) I thought something was wrong in general, but wasn't
sure how to go about it. ok - I can raise an event - right now I'm wondering
how my "parent" - a Windows form - is going to trap the event, but I need
to do some reading/coding.

Thanks Richard,
Mike
 
Back
Top