public void _SetUp() { ObjectFactory = CreateObjectFactory(true); GenericObjectDefinition threadCreatorInsideConstructor = new GenericObjectDefinition(); threadCreatorInsideConstructor.ObjectTypeName = typeof(ThreadCreatorInsideConstructor).FullName; threadCreatorInsideConstructor.IsSingleton = true; ObjectFactory.RegisterObjectDefinition("threadCreatorInsideConstructor", threadCreatorInsideConstructor); GenericObjectDefinition threadCreatorInsideDispose = new GenericObjectDefinition(); threadCreatorInsideDispose.ObjectTypeName = typeof(ThreadCreatorInsideDispose).FullName; threadCreatorInsideDispose.IsSingleton = true; ObjectFactory.RegisterObjectDefinition("threadCreatorInsideDispose", threadCreatorInsideDispose); }
public void GetObjectIsThreadSafe() { ObjectFactory = CreateObjectFactory(true); GenericObjectDefinition theSpouse = new GenericObjectDefinition(); theSpouse.ObjectTypeName = typeof(TestObject).FullName; theSpouse.IsSingleton = false; ObjectFactory.RegisterObjectDefinition("theSpouse", theSpouse); GenericObjectDefinition theObject = new GenericObjectDefinition(); theObject.ObjectTypeName = typeof(TestObject).FullName; theObject.IsSingleton = false; theObject.PropertyValues.Add("Spouse", theSpouse); ObjectFactory.RegisterObjectDefinition("theObject", theObject); AsyncTestTask t1 = new AsyncTestMethod(20000, new ThreadStart(GetTheTestObject)).Start(); AsyncTestTask t2 = new AsyncTestMethod(20000, new ThreadStart(GetTheTestObject)).Start(); AsyncTestTask t3 = new AsyncTestMethod(20000, new ThreadStart(GetTheTestObject)).Start(); AsyncTestTask t4 = new AsyncTestMethod(20000, new ThreadStart(GetTheTestObject)).Start(); t1.AssertNoException(); t2.AssertNoException(); t3.AssertNoException(); t4.AssertNoException(); }