there is a line of code
Form.VisibleChanged += Form.Invoke(new EventHandler(abc));
it says that right hand side returns an object and left side expects
System.eventhandler
and if i remove the invoke line while running i get the exception that
cross thread operation is invalid
how do i handle this so that on whenever the visiblechanged property
value changes that function abc() is executed ?
of course using this invoke
ClayB - 25 Jul 2007 09:27 GMT
Maybe code such as this will serve your purposes.
//subscribe to the event is form load
this.VisibleChanged += new EventHandler(Form1_VisibleChanged);
//the event handler checks to see if it is on the proper thread and if
not, does an Invoke to come back in on the proper thread.
void Form1_VisibleChanged(object sender, EventArgs e)
{
if (this.InvokeRequired)
{
this.Invoke(new EventHandler(Form1_VisibleChanged),
new object[] { sender, e });
}
else
{
//do whatever your want on the form's thread
}
}
===================
Clay Burch
Syncfusion, Inc.
shyamvs.prasad@gmail.com - 25 Jul 2007 14:58 GMT
I did as you said above but i still get the cross thread operation not
permitted
Sheng Jiang[MVP] - 25 Jul 2007 19:10 GMT
Using C# Anonymous Methods with Control.Invoke()
Invoke((MethodInvoker)delegate() {
//your statement here
});

Signature
Sheng Jiang
Microsoft MVP in VC++
> there is a line of code
> Form.VisibleChanged += Form.Invoke(new EventHandler(abc));
[quoted text clipped - 7 lines]
> value changes that function abc() is executed ?
> of course using this invoke