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

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

            Console.ReadKey();
            NonPersistentMemoryMapping nonPersistentMemoryMapping = new MemeoryMap.NonPersistentMemoryMapping
                                                                        ("mmfName", "mutexName");

            nonPersistentMemoryMapping.Write <Student>(student1);
            Console.WriteLine($"Write {nameof(student1)},named {student1?.Name}");
            Console.ReadKey();

            nonPersistentMemoryMapping.Write <Student>(student2);
            Console.WriteLine($"Write {nameof(student2)},named {student2?.Name}");
            Console.ReadKey();

            nonPersistentMemoryMapping.ManualDispose();
            Console.WriteLine("MemoryMapping Clear");
            Console.ReadKey();
        }
Esempio n. 2
0
 static void TestNonPersistentMemoryMapping()
 {
     while (true)
     {
         NonPersistentMemoryMapping nonPersistentMemoryMapping = new MemeoryMap.NonPersistentMemoryMapping
                                                                     ("mmfName", "mutexName");
         Student student = nonPersistentMemoryMapping.Read <Student>();
         Console.WriteLine($"Read {nameof(student)},named {student?.Name}");
         Console.ReadKey();
     }
 }