public void Multiple_Threads_Resolving() { ReaderWriterLockStatistics statistics = new ReaderWriterLockStatistics(); _machineContainer.Register.Type<Service1DependsOn2>().AsTransient(); _machineContainer.Register.Type<SimpleService2>().AsSingleton(); ThreadStart start = delegate() { for (int i = 0; i < 20; ++i) { Service1DependsOn2 service = _machineContainer.Resolve.Object<Service1DependsOn2>(); _machineContainer.Deactivate(service); } PerThreadUsages.CopyThreadUsagesToMainCollection(statistics); }; for (int i = 0; i < 30; ++i) { AddThread(start); } JoinAllThreads(); PerThreadUsages.CopyThreadUsagesToMainCollection(statistics); ReaderWriterLockStatistics.Report report = statistics.CreateReport(); Console.WriteLine(report.ToAscii()); IDictionary<Type, List<Creation>> grouped = _creations.GroupByType(); Assert.AreEqual(1, grouped[typeof(SimpleService2)].Count); Assert.AreEqual(600, grouped[typeof(Service1DependsOn2)].Count); }
public static void CopyThreadUsagesToMainCollection(ReaderWriterLockStatistics statistics) { statistics.AddUsages(_usages); _usages.Clear(); }