-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTestAlgo.cs
More file actions
129 lines (107 loc) · 2.77 KB
/
Copy pathTestAlgo.cs
File metadata and controls
129 lines (107 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Threading;
namespace Yalf.TestAssembly
{
public class TestAlgo
{
// here just for activator
public TestAlgo()
{
}
private int x;
public TestAlgo(int value = 0)
{
int v = value - 1;
x = v + 1;
}
public int Recursive(int depth)
{
if (depth <= 0)
{
Log.Info("That's it, ran out of depth");
return 0;
}
return depth + Recursive(depth - 1);
}
public void EvenOdd(int depth)
{
if (depth <= 0)
return;
if (depth % 2 == 0)
{
Log.Info("Yeah it's even, so what");
EvenOdd(depth - 2);
return;
}
else
{
EvenOdd(depth - 1);
EvenOdd(depth - 2);
return;
}
}
public void LotsOfLocalVars()
{
var i = 1;
var b = i == 0;
TestAlgo someObject1;
String someObject2;
var someObject3 = new TestSignatures();
var cont = new object();
var r = new Random();
var t = this.GetType();
if (r.NextDouble() > 0.5)
{
i++;
b = false;
cont = null;
if (i == 1)
{
var s = t.Name;
someObject1 = null;
someObject2 = null;
someObject3 = null;
}
}
}
public void SpinAThreadForWithException()
{
var t = new Thread(WithException);
t.Name = "ExceptionThread";
t.Start();
t.Join();
}
public void WithException()
{
for (int i = 5; i >= 0; i--)
{
DoSomethingExceptional(i);
}
}
private int DoSomethingExceptional(int value)
{
var x = 10 / value;
return x;
}
public void SampleWith()
{
SampleWithout();
}
public void SampleWithout()
{
return;
}
public void QueueBackgroundThread()
{
ThreadPool.QueueUserWorkItem(DummyThreadWork);
Thread.Sleep(1200);
}
public void DummyThreadWork(object ignore)
{
for (int i = 0; i < 10; i++)
{
Thread.Sleep(100);
}
}
}
}