using System; using System.Collections.Generic; using Fort23.Core; namespace Core.Utility.Event { public class EventDataBasic : IEventData ,IDisposable where T : class, new() { private static readonly Queue queue = new Queue(); public bool isHuiShou; public void Recycle() { Dispose(); } public static T Create() { if (queue.Count <= 0) { T t = new T(); return t; } T VALUE = queue.Dequeue(); // System.GC.ReRegisterForFinalize(VALUE); return VALUE; } public static void Recycle(T data) { if (data == null || queue.Contains(data)) { return; } if (queue.Count > 10) { return; } // System.GC.SuppressFinalize(data); queue.Enqueue(data); } protected EventDataBasic() { } public void Dispose() { ProDispose(); Recycle(this as T); } protected virtual void ProDispose() { } } }