Hi Ken,
thanks again for trying to help me. The application where I am working
around is still the same.
I tried to do the following with tcp.
I wrote an eventhandler, named eventwrapper. He was instanced by the form by
passing the form itself and a forms delegate to the constructor.
The eventhandler provided an event procedure. This procedure was registered
to listening events of my server. When the event occured he executed
something like form.Invoke(formsDelegate).
But as soon as the delegate tried to modify GUI elements. The application
hang?
What is wrong with that. Do you know an example for managing this.
Thanks - Patrick
> The most likely source of your problem is that you're not using the
> Form.Invoke() method to marshal the call to your UI thread before changing
[quoted text clipped - 31 lines]
> >
> > Thanks - Patrick
Ryan Berry - 30 Sep 2004 15:08 GMT
Patrick,
I'm not sure I follow what you tried to do with "tcp". What Ken is
saying is that you should not modify GUI elements from any other thread
than the main GUI thread; thus, you need to use form.invoke. Here's an
example: (I used 2 parameters to show how to use the object array)
Delegate Definition:
private delegate void EventCompleteCB(string Message,in Value);
Event Delegate: (IE: Method that is calledback on when the event is
raised)
private void EventComplete(string Message, int Value)
{
Object[] param = {Message,Value};
this.Invoke(new EventCompleteCB(InternalEventComplete),param);
}
Internal Form GUI Update Method:
private void InternalEventComplete(string Message, int Value)
{
// Only update GUI elements here
[formControl].Text = Message;
}
Hope this helps.
-- Ryan Berry
Ken Kolda - 30 Sep 2004 16:19 GMT
That certainly sounds reasonable -- if your wrapper is calling Form.Invoke()
then you should be good. If you can post a very simple project that
demonstrates this problem, that might be helpful.
Ken
> Hi Ken,
> thanks again for trying to help me. The application where I am working
[quoted text clipped - 52 lines]
> > >
> > > Thanks - Patrick