コード例 #1
0
ファイル: Class1.cs プロジェクト: uunniie/ctnew
    public static void Main(string[] args)
    {
        //在更新数据前显示对象信息
        PersonDAL personDAL = new PersonDAL();
        var beforeObj = personDAL.GetPerson(24);
        personDAL.Display("Before", beforeObj);

        //更新Person的SecondName,Age两个属性
        Person person1 = new Person();
        person1.Id = 24;
        person1.FirstName = "Leslie";
        person1.SecondName = "Wang";
        person1.Age = 32;
        person1.Address = "Tianhe";
        person1.Telephone = "13660123456";
        person1.EMail = "*****@*****.**";

        //更新Person的FirstName属性
        Person person2 = new Person();
        person2.Id = 24;
        person2.FirstName = "Rose";
        person2.SecondName = "Lee";
        person2.Age = 34;
        person2.Address = "Tianhe";
        person2.Telephone = "13660123456";
        person2.EMail = "*****@*****.**";

        //使用异步方式同时更新数据
        MyDelegate myDelegate = new MyDelegate(personDAL.Update);
        myDelegate.BeginInvoke(person1, null, null);
        myDelegate.BeginInvoke(person2, null, null);

        Thread.Sleep(300);
        //在更新数据后显示对象信息
        var afterObj = personDAL.GetPerson(24);
        personDAL.Display("After", afterObj);
        Console.ReadKey();
    }