In a windows forms project i have subscribed to global keyboard event using win32 api to fire an event when i press win + alt + E, in the event handler i have this code:
_rectangle = new ScreenBoundingRectangle();
_rectangle.Location = Location;
_rectangle.Visible = true;
i keep a variable to my rectangle, now based on some logic, i want to hide the rectangle so i set the visibility to false using this line of code:
_rectangle.Visible = false;
However i get the famous cross threading exception, even if i try this :
this.Invoke(new MethodInvoker(() =>
{
_rectangle.Visible = false;
}));
i still get the cross threading exception!
the _rectangle does not have invoke method, is there is any other way around this ?