Exemple #1
0
        private Task ReportState()
        {
            Debug.WriteLine("SmMediaManager.ReportState() state {0} message {1}", _mediaState, _mediaStateMessage);
            MediaManagerState state;
            string            message;

            lock (_lock)
            {
                state              = _mediaState;
                message            = _mediaStateMessage;
                _mediaStateMessage = null;
            }

            OnStateChange?.Invoke(this, new MediaManagerStateEventArgs(state, message));
            if (null != message)
            {
                IMediaStreamConfigurator streamConfigurator = _mediaStreamConfigurator;
                streamConfigurator?.ReportError(message);
            }
            return(TplTaskExtensions.CompletedTask);
        }
        private Task ReportState()
        {
            Debug.WriteLine("SingleStreamMediaManager.ReportState() state {0} message {1}", (object)this._mediaState, (object)this._mediaStateMessage);
            bool              lockTaken = false;
            object            obj;
            MediaManagerState state;
            string            message;

            try
            {
                Monitor.Enter(obj       = this._lock, ref lockTaken);
                state                   = this._mediaState;
                message                 = this._mediaStateMessage;
                this._mediaStateMessage = (string)null;
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(obj);
                }
            }
            EventHandler <MediaManagerStateEventArgs> eventHandler = this.OnStateChange;

            if (null != eventHandler)
            {
                eventHandler((object)this, new MediaManagerStateEventArgs(state, message));
            }
            if (null != message)
            {
                IMediaStreamConfigurator streamConfigurator = this._mediaStreamConfigurator;
                if (null != streamConfigurator)
                {
                    streamConfigurator.ReportError(message);
                }
            }
            return(TplTaskExtensions.CompletedTask);
        }