예제 #1
0
        /// <summary>
        /// 进程发送消息
        /// </summary>
        /// <returns></returns>
        public bool SendMessage(string message)
        {
            memoryFile.WriteData(message);

            if (eventWait != null)
            {
                eventWait.Set();

                //暂时未处理 批量快速发消息 会导致接受不全【写入速度过快,读取速度跟不上】

                Thread.Sleep(10);

                eventWait.Reset();//如果注释掉这句代码   A先发送消息,B在运行程序也会收到
                return(true);
            }
            return(false);
        }
예제 #2
0
 /// <summary>
 /// 将当前主窗口 句柄写入到进程内存,方便激活
 /// </summary>
 /// <param name="processKey"></param>
 /// <param name="windowHandel"></param>
 public static void WriteHandel(string processKey, IntPtr windowHandel)
 {
     fileMapped = MemoryMappedFileHelper.CreateMemoryMappedFileObj(processKey + handelTag);
     fileMapped.WriteData(windowHandel.ToString());
 }