I have problem when switching a panels visibility to false which freezes the application. I have a menu on the left site including several buttons. When clicking a button the respective panel is shown and all others are hidden. This works quite well. But I also used small panels indicating when an error message is received by my app.
When I then click the corresponding button I want the panel to disappear and here it is where the application will get stucked. Unfortunately there is no error message. The code shows the event handler and the called method which is used by all menu buttons.
private void butVEndpoint_Click(object sender, EventArgs e)
{
changePanelVisibility(butVEndpoint, pnlvEndpointContent, pnlErrorvEndpoint);
}
private void changePanelVisibility(Button currentButton, Panel currentPanel, Panel currentErrorPanel)
{
pnlActiveButton.Height = currentButton.Height;
pnlActiveButton.Top = currentButton.Top;
//Chaninging all content panels to visible = false
pnlAppSetContent.Visible = false;
pnlEkraContent.Visible = false;
pnlKYContent.Visible = false;
pnlSip1Content.Visible = false;
pnlSip2Content.Visible = false;
pnlRehmContent.Visible = false;
pnlViscContent.Visible = false;
pnlvEndpointContent.Visible = false;
//changing the relevant content panel to visible = true
currentPanel.Visible = true;
//changing the error panel to visible = false -> here the code will get stucked
currentErrorPanel.Visible = false;
}
The error panel is set to visible = true during an event which recognizes an incoming message. But the thread is/should already be closed when clicking the button afterwards. Is there something else which I don't see? And why does it work with the other panels and only my "error panels" dont work?
Error panel next to the button where the message arrived
This is the code where the panel is set to visible = true.
private void Endpoint_OnCFXMessageReceived(AmqpChannelAddress source, CFXEnvelope message)
{
pnlErrorvEndpoint.Visible = true;
Application.DoEvents();
}