예제 #1
0
파일: QuickIPC.cs 프로젝트: dbose/QuickIPC
        public void Poke(string somedata)
        {
            lock(m_SyncRoot)
            {
                using (MemoryMappedFileStream fs = new MemoryMappedFileStream(m_MappedMemoryName,
                                                                          MAX_LENGTH,
                                                                          MemoryProtection.PageReadWrite))
                {
                    fs.MapViewToProcessMemory(0, MAX_LENGTH);
                    fs.Write(Encoding.ASCII.GetBytes(somedata + "\0"), 0, somedata.Length + 1);
                }

                //
                //Signal the "Please Read" event and waits on "Read Done"
                EventWaitHandle.SignalAndWait(m_NamedEventHandle,
                                              m_NamedEventBuddyHandle,
                                              20000,
                                              false);
                m_NamedEventBuddyHandle.Reset();
            }
        }
예제 #2
0
파일: QuickIPC.cs 프로젝트: dbose/QuickIPC
 public string Peek()
 {
     byte[] buffer;
     using (MemoryMappedFileStream fs = new MemoryMappedFileStream(m_MappedMemoryName,
                                                                   MAX_LENGTH,
                                                                   MemoryProtection.PageReadWrite))
     {
         fs.MapViewToProcessMemory(0, MAX_LENGTH);
         buffer = new byte[MAX_LENGTH];
         fs.Read(buffer, 0, buffer.Length);
     }
     string readdata = Encoding.ASCII.GetString(buffer, 0, buffer.Length);
     return readdata.Substring(0, readdata.IndexOf('\0'));
 }