Esempio n. 1
0
        static void TestPersistentMemoryMapping()
        {
            Student student1 = new Student()
            {
                Name = "111"
            };
            Student student2 = new Student()
            {
                Name = "222"
            };

            Console.WriteLine("起两个程序然后依次按回车");

            Console.ReadKey();
            using (PersistentMemoryMapping pmm = new MemeoryMap.PersistentMemoryMapping("MyMemoryMap", "map.data", "myLock"))
            {
                pmm.Write <Student>(student1);
                Console.WriteLine($"Write {nameof(student1)},named {student1?.Name}");
            }
            Console.ReadKey();

            using (PersistentMemoryMapping pmm = new MemeoryMap.PersistentMemoryMapping("MyMemoryMap", "map.data", "myLock"))
            {
                pmm.Write <Student>(student2);
                Console.WriteLine($"Write {nameof(student2)},named {student2?.Name}");
            }
            Console.ReadKey();

            //using (PersistentMemoryMapping pmm = new MemeoryMap.PersistentMemoryMapping("MyMemoryMap", "map.data", "myLock"))
            //{
            //    pmm.Write<List<Student>>(new List<Student>() { student1 , student2 });
            //    Console.WriteLine($"Write {nameof(student2)},named {student2?.Name}");
            //}
            //Console.ReadKey();
        }
Esempio n. 2
0
 static void TestPersistentMemoryMapping()
 {
     while (true)
     {
         using (PersistentMemoryMapping pmm = new MemeoryMap.PersistentMemoryMapping("MyMemoryMap", "map.data", "myLock"))
         {
             Student student = pmm.Read <Student>();
             Console.WriteLine($"Read {nameof(student)},named {student?.Name}");
         }
         Console.ReadKey();
     }
 }