Beispiel #1
0
 public void SetResultListener(TListener resultListener)
 {
     lock (_listenerReference.ListenerLock)
     {
         if (_listenerReference.ResultListener != null)
         {
             throw new InvalidOperationException("Result listener already set");
         }
         // NOTE: exception throwing call first
         _listenerResultStream = StartResultStream();
         _listenerResultStream.MessageReceived += _listenerReference.ListenerResultReceived;
         _listenerReference.ResultListener      = resultListener;
     }
 }
Beispiel #2
0
        private ClientResultStream StartResultStream()
        {
            var clientResultStream = new ClientResultStream(FudgeContext, _mqTemplate);

            try
            {
                REST.Resolve("startJmsResultStream").PostFudge(new FudgeMsg(FudgeContext)
                {
                    { "destination", clientResultStream.QueueName }
                });
                clientResultStream.WaitForStartSignal();
                return(clientResultStream);
            }
            catch
            {
                clientResultStream.Dispose();
                throw;
            }
        }
Beispiel #3
0
        private void RemoveResultListenerInner(bool throwOnNotSet)
        {
            ClientResultStream listenerResultStream;

            lock (_listenerReference.ListenerLock)
            {
                if (_listenerReference.ResultListener == null)
                {
                    if (throwOnNotSet)
                    {
                        throw new InvalidOperationException("Result listener not currently set");
                    }
                    return;
                }
                _listenerReference.ResultListener = null;

                listenerResultStream  = _listenerResultStream;
                _listenerResultStream = null;
                StopResultStream();
            }
            listenerResultStream.Dispose(); // If this is done in the lock then dispose can deadlock
        }