Example #1
0
        public static InProcListener GetListener(string aPath)
        {
            InProcListener Result;

            fLock.AcquireReaderLock(0x7fffffff);
            try
            {
                if (!fQueue.TryGetValue(aPath, out Result))
                {
                    LockCookie lCookie = fLock.UpgradeToWriterLock(0x7fffffff);
                    try
                    {
                        if (!fQueue.TryGetValue(aPath, out Result))
                        {
                            Result = new InProcListener(aPath);
                            fQueue.Add(aPath, Result);
                        }
                    }
                    finally
                    {
                        fLock.DowngradeFromWriterLock(ref lCookie);
                    }
                }
                Result.AddRef();
            }
            finally
            {
                fLock.ReleaseReaderLock();
            }
            return(Result);
        }
Example #2
0
 public static void ReleaseListener(InProcListener aRef)
 {
     fLock.AcquireReaderLock(0x7fffffff);
     try
     {
         aRef.RemoveRef();
     }
     finally
     {
         fLock.ReleaseReaderLock();
     }
 }
Example #3
0
        public static void RemoveListener(string aPath, Action <object> aListener)
        {
            InProcListener lWork;

            fLock.AcquireWriterLock(0x7fffffff);
            try
            {
                if (!fQueue.TryGetValue(aPath, out lWork))
                {
                    lWork = new InProcListener(aPath);
                    fQueue.Add(aPath, lWork);
                }
            }
            finally
            {
                fLock.ReleaseWriterLock();
            }
            lock (lWork)
                lWork.Remove(aListener);
        }
Example #4
0
        public static InProcListener AddListener(string aPath, Action <object> aListener)
        {
            InProcListener Result;

            fLock.AcquireWriterLock(0x7fffffff);
            try
            {
                if (!fQueue.TryGetValue(aPath, out Result))
                {
                    Result = new InProcListener(aPath);
                    fQueue.Add(aPath, Result);
                }
            }
            finally
            {
                fLock.ReleaseWriterLock();
            }
            lock (Result)
                Result.AddLast(aListener);

            return(Result);
        }
Example #5
0
 public override void Dispose()
 {
     InProcServer.ReleaseListener(this.fChannel);
     this.fChannel = null;
 }
Example #6
0
 public InProcSend(InProcListener aChannel)
 {
     this.fChannel = aChannel;
 }
Example #7
0
 public InProcReceive(InProcQueue aOwner, string aName)
 {
     this.fMessages = new LinkedList <object>();
     this.fOwner    = aOwner;
     this.fChannel  = InProcServer.AddListener(aName, new Action <object>(this.Callback));
 }