Question

I have a Form which has code similar to this:

public partial class Form1 : Form
{
    private int m_var1;
    private int m_var2;
    string sMsg;
    bool bReturn;

    private bool MyFunction()
    {
        // POINT A: at this point m_var1 and m_var2 are both 100            
        sMsg = "Test Message";
        bReturn = (DialogResult.Yes == MessageBox.Show(sMsg, "MyApp",MessageBoxButtons.YesNo, MessageBoxIcon.Question));
        // POINT B: at this point m_var1 and m_var2 are both 0
    }
}

Why at POINT B have m_var1 and m_var2 both changed to 0 as I am experiencing?

Was it helpful?

Solution

This sounds like a thread issue. I can explain how I would try to solve this problem:

  • Change m_var1 and m_var2 to Properties.
  • Set a breakpoint to their setters.

Check the stacktrace of the code that hit the setter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top