wasSharpNET – Diff between revs 11 and 27
?pathlinks?
Rev 11 | Rev 27 | |||
---|---|---|---|---|
Line 17... | Line 17... | |||
17 | /// A command-line spinner indicating activity. |
17 | /// A command-line spinner indicating activity. |
|
18 | /// </summary> |
18 | /// </summary> |
|
19 | public class ConsoleSpin : IDisposable |
19 | public class ConsoleSpin : IDisposable |
|
20 | { |
20 | { |
|
21 | private static readonly CircularQueue<string> spinArt = |
21 | private static readonly CircularQueue<string> spinArt = |
|
22 | new CircularQueue<string>(new[] { ".oOo", "oOo.", "Oo.o", "o.oO" }); |
22 | new CircularQueue<string>(new[] {".oOo", "oOo.", "Oo.o", "o.oO"}); |
|
Line 23... | Line 23... | |||
23 | |
23 | |
|
24 | private static readonly ManualResetEvent spinEvent = new ManualResetEvent(false); |
24 | private static readonly ManualResetEvent spinEvent = new ManualResetEvent(false); |
|
25 | private static Thread spinThread; |
25 | private static Thread spinThread; |
|
Line 57... | Line 57... | |||
57 | { |
57 | { |
|
58 | if (spinThread != null) |
58 | if (spinThread != null) |
|
59 | { |
59 | { |
|
60 | run = false; |
60 | run = false; |
|
61 | spinEvent.Reset(); |
61 | spinEvent.Reset(); |
|
62 | if ((!spinThread.ThreadState.Equals(ThreadState.Running) && |
62 | if (!spinThread.ThreadState.Equals(ThreadState.Running) && |
|
63 | !spinThread.ThreadState.Equals(ThreadState.WaitSleepJoin)) || spinThread.Join(1000)) |
63 | !spinThread.ThreadState.Equals(ThreadState.WaitSleepJoin) || spinThread.Join(1000)) |
|
64 | return; |
64 | return; |
|
65 | spinThread.Abort(); |
65 | spinThread.Abort(); |
|
66 | spinThread.Join(); |
66 | spinThread.Join(); |
|
67 | } |
67 | } |
|
68 | } |
68 | } |
|
Line 84... | Line 84... | |||
84 | public void Stop() |
84 | public void Stop() |
|
85 | { |
85 | { |
|
86 | spinEvent.Reset(); |
86 | spinEvent.Reset(); |
|
87 | } |
87 | } |
|
88 | } |
88 | } |
|
89 | } |
89 | } |
|
90 | |
90 | |