public WeakReference(T target, IReferenceQueue <T> queue, bool trackResurrection) : base(queue) { systemReference = new System.WeakReference(target, trackResurrection); CreateFinalizerListener(); }
public KeyedTimedReference(K key, V reference, IReferenceQueue <V> referenceQueue, TimeSpan timeout) : base(reference, referenceQueue) { this.Key = key; this.HardReference = reference; this.LastAccess = DateTime.Now; this.TimeOut = timeout; }
/// <summary> /// Constructs a new <see cref="TimedReference{T}"/> /// </summary> /// <param name="target">The reference target</param> /// <param name="timeout"> /// The minimum amount of time the reference target should be uncollectable for /// after each access to the <see cref="Target"/> property. /// </param> /// <param name="queue">The references associated <see cref="IReferenceQueue{T}"/></param> /// <param name="trackResurrection"> /// True if the current reference should continue to reference the <see cref="Target"/> /// after it has been resurrected. /// </param> public TimedReference(T target, TimeSpan timeout, IReferenceQueue <T> queue, bool trackResurrection) : base(queue) { hardReference = target; timeOut = timeout; targetTime = DateTime.Now + timeout; systemReference = new System.WeakReference(target, trackResurrection); CreateTimer(); CreateFinalizerListener(); }
/// <summary> /// Places this reference onto its associated <see cref="IReferenceQueue{T}"/>. /// </summary> /// <returns> /// True if the <see cref="Reference{T}"/> was placed on the <see cref="IReferenceQueue{T}"/> /// otherwise False if no <see cref="IReferenceQueue{T}"/> is associated or if the /// <see cref="Reference{T}"/> has already been enqueued. /// </returns> protected virtual bool Enqueue() { if (referenceQueue != null && nextOnQueue == null) { referenceQueue.Enqueue(this); referenceQueue = null; return(true); } return(false); }
public WeakReference(T target, IReferenceQueue <T> queue) : this(target, queue, false) { }
/// <summary> /// Constructs a new <see cref="Reference{T}"/> /// </summary> /// <param name="referenceQueue">The reference's associated <see cref="IReferenceQueue{T}"/></param> protected Reference(IReferenceQueue <T> referenceQueue) { this.referenceQueue = referenceQueue; }
/// <summary> /// Constructs a new <see cref="Reference{T}"/> /// </summary> protected Reference() { referenceQueue = null; }
/// <summary> /// Constructs a new <see cref="TimedReference{T}"/> /// </summary> /// <param name="target">The reference target</param> /// <param name="timeout"> /// The minimum amount of time the reference target should be uncollectable for /// after each access to the <see cref="Target"/> property. /// </param> /// <param name="queue">The references associated <see cref="IReferenceQueue{T}"/></param> public TimedReference(T target, TimeSpan timeout, IReferenceQueue <T> queue) : this(target, timeout, queue, false) { }
public KeyedWeakReference(K key, V reference, IReferenceQueue <V> referenceQueue) : base(reference, referenceQueue) { this.Key = key; }