T
Tony
Most of the time I'm asking why something doesn't work but this time I'm
baffled as why this DOES work....
Note that the local variables wBatchUC, wModalPromptUC, and wBatchFlowPanel
are all stack variables and after the method executes, the stack rolls back,
but when the event handler gets called, the stack variables still retain the
original values - I have no idea why or how this works but the code works
flawlessly.
internal void DeleteBatch(BatchUC wBatchUC)
{
this.InModalMode = true;
ModalPromptUC wModalPromptUC = new ModalPromptUC(this, "You are
about to delete this batch, are you sure?");
wModalPromptUC.Initialize(m_oIAActiveUISnapin);
wModalPromptUC.Visible = false;
BatchFlowPanel wBatchFlowPanel = FindBatchFlowPanel(wBatchUC);
wBatchFlowPanel.Controls.Add(wModalPromptUC);
wBatchFlowPanel.Controls.SetChildIndex(wModalPromptUC,
wBatchFlowPanel.Controls.GetChildIndex(wBatchUC) + 1);
AnimateHideShow(null, wModalPromptUC);
wModalPromptUC.Reply += delegate(DialogResult eDialogResult)
{
AnimateHideShow(wModalPromptUC, null);
this.InModalMode = false;
if (eDialogResult == DialogResult.Yes)
{
wBatchUC.IABatch.Delete();
if (m_wSelectedwBatchUC == wBatchUC)
m_wSelectedwBatchUC = null;
m_wBatchFlowPanels.Controls.Remove(wBatchFlowPanel);
wBatchUC.Dispose();
}
else
wBatchFlowPanel.Controls.Remove(wModalPromptUC);
wModalPromptUC.Dispose();
this.InModalMode = false;
};
}
baffled as why this DOES work....
Note that the local variables wBatchUC, wModalPromptUC, and wBatchFlowPanel
are all stack variables and after the method executes, the stack rolls back,
but when the event handler gets called, the stack variables still retain the
original values - I have no idea why or how this works but the code works
flawlessly.
internal void DeleteBatch(BatchUC wBatchUC)
{
this.InModalMode = true;
ModalPromptUC wModalPromptUC = new ModalPromptUC(this, "You are
about to delete this batch, are you sure?");
wModalPromptUC.Initialize(m_oIAActiveUISnapin);
wModalPromptUC.Visible = false;
BatchFlowPanel wBatchFlowPanel = FindBatchFlowPanel(wBatchUC);
wBatchFlowPanel.Controls.Add(wModalPromptUC);
wBatchFlowPanel.Controls.SetChildIndex(wModalPromptUC,
wBatchFlowPanel.Controls.GetChildIndex(wBatchUC) + 1);
AnimateHideShow(null, wModalPromptUC);
wModalPromptUC.Reply += delegate(DialogResult eDialogResult)
{
AnimateHideShow(wModalPromptUC, null);
this.InModalMode = false;
if (eDialogResult == DialogResult.Yes)
{
wBatchUC.IABatch.Delete();
if (m_wSelectedwBatchUC == wBatchUC)
m_wSelectedwBatchUC = null;
m_wBatchFlowPanels.Controls.Remove(wBatchFlowPanel);
wBatchUC.Dispose();
}
else
wBatchFlowPanel.Controls.Remove(wModalPromptUC);
wModalPromptUC.Dispose();
this.InModalMode = false;
};
}
