Stream destream = new FileStream("F:\\TestTxt.txt", FileMode.Open,
FileAccess.Read, FileShare.Read);
var stillme = (Person)formatter.Deserialize(destream);
var stillme1 = (Person)formatter.Deserialize(destream);
Console.WriteLine(stillme.DisplayInfo());
Console.WriteLine(stillme1.DisplayInfo());
destream.Close();
Console.ReadLine();
}
}
}
运行结果:
其它两种方式就不再实验了,搞定!
C#多线程编程实例 线程与窗体交互【附源码】