We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 494dfb0 commit 9c91e57Copy full SHA for 9c91e57
test/DryIoc.IssuesTests/GHIssue337_Singleton_is_created_twice.cs
@@ -0,0 +1,37 @@
1
+using System;
2
+using System.Threading;
3
+using System.Threading.Tasks;
4
+using NUnit.Framework;
5
+
6
+namespace DryIoc.IssuesTests
7
+{
8
+ [TestFixture]
9
+ public class GHIssue337_Singleton_is_created_twice
10
+ {
11
+ [Test]
12
+ public void Test()
13
14
+ var container = new Container();
15
+ container.Register<A>(Reuse.Singleton);
16
17
+ var ts = new Task[8];
18
+ for (int i = 0; i < ts.Length; i++)
19
20
+ ts[i] = Task.Run(() => container.Resolve<A>());
21
+ }
22
23
+ Task.WaitAll(ts);
24
25
26
+ class A
27
28
+ public static int Counter;
29
+ public A()
30
31
+ Thread.Sleep(100);
32
+ Console.WriteLine(++Counter);
33
34
35
36
37
+}
0 commit comments