void IActivityMonitorBoundClient.SetMonitor(IActivityMonitorImpl?source, bool forceBuggyRemove)
 {
     if (source != null && _source != null)
     {
         throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException(this);
     }
     // Silently ignore null => null or monitor => same monitor.
     if (source != _source)
     {
         _prevLogType = LogEntryType.None;
         _prevlogTime = DateTimeStamp.Unknown;
         Debug.Assert((source == null) != (_source == null));
         if ((_source = source) == null)
         {
             if (_file != null)
             {
                 _file.Close();
             }
             _file = null;
         }
         else
         {
             // If initialization failed, we let the file null: this monitor will not
             // work (the error will appear in the Critical errors) but this avoids
             // an exception to be thrown here.
             var f = new MonitorBinaryFileOutput(_path, _source.UniqueId, _maxCountPerFile, _useGzipCompression);
             if (f.Initialize(_source.InternalMonitor))
             {
                 var g = _source.CurrentGroup;
                 _currentGroupDepth = g != null ? g.Depth : 0;
                 _file = f;
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// forceBuggyRemove is not used here since this client is not lockable.
 /// </summary>
 void IActivityMonitorBoundClient.SetMonitor(IActivityMonitorImpl source, bool forceBuggyRemove)
 {
     if (source != null && _monitorSource != null)
     {
         throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException(this);
     }
     // Silently ignore null => null or monitor => same monitor.
     if (source != _monitorSource)
     {
         _currentMinimalFilter = LogFilter.Undefined;
         _prevLogType          = LogEntryType.None;
         _prevlogTime          = DateTimeStamp.Unknown;
         Debug.Assert((source == null) != (_monitorSource == null));
         if ((_monitorSource = source) == null)
         {
             // Releases the channel if any.
             _channel = null;
         }
         else
         {
             var g = _monitorSource.CurrentGroup;
             _currentGroupDepth = g != null ? g.Depth : 0;
             Interlocked.Increment(ref _version);
         }
     }
 }
示例#3
0
 void IActivityMonitorBoundClient.SetMonitor(IActivityMonitorImpl source, bool forceBuggyRemove)
 {
     if (source != null && _source != null)
     {
         throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException(this);
     }
     if (source != null)
     {
         Interlocked.Exchange(ref _text, Util.Array.Empty <string>());
         _source = source;
     }
     else
     {
         _source = null;
     }
 }
 /// <summary>
 /// forceBuggyRemove is not used here since this client is not lockable.
 /// </summary>
 void IActivityMonitorBoundClient.SetMonitor(IActivityMonitorImpl?source, bool forceBuggyRemove)
 {
     if (source != null && _monitorSource != null)
     {
         throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException(this);
     }
     // Silently ignore null => null or monitor => same monitor.
     if (source != _monitorSource)
     {
         _prevLogType = LogEntryType.None;
         _prevlogTime = DateTimeStamp.Unknown;
         Debug.Assert((source == null) != (_monitorSource == null));
         if ((_monitorSource = source) != null)
         {
             var g = _monitorSource.CurrentGroup;
             _currentGroupDepth = g != null ? g.Depth : 0;
         }
     }
 }