Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                producer = new SharedMemory("noname1", 255);
                consumer = new SharedMemory("noname2", 255);
            }
            else
            {
                producer = new SharedMemory("noname2", 255);
                consumer = new SharedMemory("noname1", 255);
            }

            consumer.ReceiveHandler += new ReceivedEventHandler<byte[]>(Program.HandleConsumerReceiveEvent);

            //Console.WriteLine("Press return to start ");
            //Console.ReadLine();
            if (args.Length > 0)
            {
                Console.WriteLine("Sending PING");
                producer.Write(ASCIIEncoding.ASCII.GetBytes("PING: " + DateTime.Now.ToString()));
            }

            Console.WriteLine("Press return to exit ");
            Console.ReadLine();
            consumer.Close();
            producer.Close();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Unmaps the view of file.
 /// </summary>
 public void UnmapViewOfFile()
 {
     SharedMemory.UnmapViewOfFile(_ptr);
     _ptr = IntPtr.Zero;
 }