Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            var test1 = Singleton_t.GetInstance();

            Invoke(new show(showTextbox), new object[] { "初始值:" + test1.strData });
            test1.data    = 1;
            test1.strData = "1";
            Invoke(new show(showTextbox), new object[] { "赋值后:" + test1.strData });
            var test2 = Singleton_t.GetInstance();

            Invoke(new show(showTextbox), new object[] { "获取的第二个实例值:" + test2.strData });
            TestModel test3 = new TestModel();

            test3.Initializer();
            Invoke(new show(showTextbox), new object[] { "在另一个类中的作为成员变量时:" + test3.m_test.strData });
            test1.strData = "3";
            Invoke(new show(showTextbox), new object[] { "所有实例同步变化:" + test3.m_test.strData });
        }
Ejemplo n.º 2
0
 public void Initializer()
 {
     m_test = Singleton_t.GetInstance();
 }