/// <summary> /// /// </summary> /// <returns></returns> public static IEnumerable <InstrumentBase> ClearAllInstruments() { List <InstrumentBase> insts = new List <InstrumentBase>(); try { InstrumentManager.InstExclusiveLockObject.EnterWriteLock(); for (int i = instruments.Count - 1; i >= 0; i--) { for (int j = instruments[i].Count - 1; j >= 0; j--) { instruments[i][j].Dispose(); instruments[i].RemoveAt(j); } } InstrumentRemoved?.Invoke(typeof(InstrumentManager), EventArgs.Empty); } finally { InstrumentManager.InstExclusiveLockObject.ExitWriteLock(); } return(insts.AsEnumerable()); }
/// <summary> /// /// </summary> /// <param name="instrumentType"></param> public static void RemoveInstrument(InstrumentType instrumentType) { try { InstrumentManager.InstExclusiveLockObject.EnterWriteLock(); var list = instruments[(int)instrumentType]; list[list.Count - 1].Dispose(); list.RemoveAt(list.Count - 1); InstrumentRemoved?.Invoke(typeof(InstrumentManager), EventArgs.Empty); } finally { InstrumentManager.InstExclusiveLockObject.ExitWriteLock(); } }