A GrandOutputClient is a IActivityMonitorClient that can only be obtained and registered through GrandOutput.Register.
Inheritance: IActivityMonitorBoundClient
Beispiel #1
0
        /// <summary>
        /// Ensures that a client for this GrandOutput is registered on a monitor.
        /// </summary>
        /// <param name="monitor">The monitor onto which a <see cref="GrandOutputClient"/> must be registered.</param>
        /// <returns>A newly created client or the already existing one.</returns>
        public GrandOutputClient Register(IActivityMonitor monitor)
        {
            if (monitor == null)
            {
                throw new ArgumentNullException("monitor");
            }
            AttemptGarbageDeadClients();
            Func <GrandOutputClient> reg = () =>
            {
                var c = new GrandOutputClient(this);
                lock (_clients) _clients.Add(new WeakReference <GrandOutputClient>(c));
                return(c);
            };

            return(monitor.Output.RegisterUniqueClient(b => b.Central == this, reg));
        }
        GrandOutputClient?DoEnsureGrandOutputClient(IActivityMonitor monitor)
        {
            GrandOutputClient?Register()
            {
                var c = new GrandOutputClient(this);

                lock ( _clients )
                {
                    if (IsDisposed)
                    {
                        c = null;
                    }
                    else
                    {
                        _clients.Add(new WeakReference <GrandOutputClient>(c));
                    }
                }
                return(c);
            }

            return(monitor.Output.RegisterUniqueClient(b => { Debug.Assert(b != null); return b.Central == this; }, Register));
        }
Beispiel #3
0
 /// <summary>
 /// Ensures that a client for this GrandOutput is registered on a monitor.
 /// </summary>
 /// <param name="monitor">The monitor onto which a <see cref="GrandOutputClient"/> must be registered.</param>
 /// <returns>A newly created client or the already existing one.</returns>
 public GrandOutputClient Register( IActivityMonitor monitor )
 {
     if( monitor == null ) throw new ArgumentNullException( "monitor" );
     AttemptGarbageDeadClients();
     Func<GrandOutputClient> reg = () =>
         {
             var c = new GrandOutputClient( this );
             lock( _clients ) _clients.Add( new WeakReference<GrandOutputClient>( c ) ); 
             return c;
         };
     return monitor.Output.RegisterUniqueClient( b => b.Central == this, reg );
 }