Example #1
0
        /// <summary>
        /// Releases all unmanaged resources used by the object, and potentially releases managed resources.
        /// </summary>
        /// <param name="disposing">true to dispose of managed resources; otherwise false.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!fDisposed)
            {
                if (disposing)
                {
                    #if IPC_SUPPORTS
                    if (fSingleInstanceMutex != null)
                    {
                        fSingleInstanceMutex.Close();
                        fSingleInstanceMutex = null;
                    }

                    if (fIpcChannel != null)
                    {
                        ChannelServices.UnregisterChannel(fIpcChannel);
                        fIpcChannel = null;
                    }
                    #else
                    IpcFake.StopServer();
                    IpcFake.ReleaseAllMutexes();
                    #endif
                }

                fDisposed = true;
            }
        }
Example #2
0
        public void Test_IpcFake()
        {
            IpcFake.StartServer(GetSingleInstanceEnforcer());

            Assert.AreEqual(true, IpcFake.CreateMutex("test", true));
            IpcFake.RefreshMutexes();

            Assert.AreEqual(false, IpcFake.CreateMutex("test", true));
            IpcFake.RefreshMutexes();

            Assert.Throws(typeof(ArgumentNullException), () => { IpcFake.SendMessage(null); });

            IpcFake.SendMessage(IpcFake.CmdSendArgs, new string[] { "testArgX" });

            IpcFake.StopServer();
            IpcFake.ReleaseAllMutexes();
        }