Skip to content

Commit

Permalink
Added double check to avoid NullReferenceException if no message is p…
Browse files Browse the repository at this point in the history
…assed to WorkAsync method
  • Loading branch information
MscrmTools committed Oct 31, 2023
1 parent 1dfd932 commit 6619456
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions XrmToolBox.Extensibility/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,22 @@ public void WorkAsync(WorkAsyncInfo info)

_worker.RunWorkerCompleted += (s, e) =>
{
_infoPanel?.SendToBack();

if (info.Host.Controls.Contains(_infoPanel))
if (_infoPanel != null)
{
info.Host.Controls.Remove(_infoPanel);
}
_infoPanel.SendToBack();

if (_infoPanel?.Tag is Control c && c.Controls.Contains(_infoPanel))
{
c.Controls.Remove(_infoPanel);
}
if (info?.Host?.Controls.Contains(_infoPanel) ?? false)
{
info.Host.Controls.Remove(_infoPanel);
}

if (_infoPanel.Tag is Control c && (c?.Controls.Contains(_infoPanel) ?? false))
{
c.Controls.Remove(_infoPanel);
}

_infoPanel?.Dispose();
_infoPanel.Dispose();
}

if (info.PostWorkCallBack != null)
{
Expand Down

0 comments on commit 6619456

Please sign in to comment.