-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPickThread.cs
More file actions
59 lines (50 loc) · 1.73 KB
/
Copy pathPickThread.cs
File metadata and controls
59 lines (50 loc) · 1.73 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
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Threading;
namespace RandomFilePicker
{
static class PickThread
{
private static Thread mainThread;
private static Boolean stopFlag = false;
private static Monitor mainWindow;
#region constructor
public static void StartThread(Monitor monitorWindow)
{
mainWindow = monitorWindow;
mainThread = new Thread(new ThreadStart(mainThreadProcess));
mainThread.Start();
}
#endregion
#region Thread
private static void mainThreadProcess()
{
int repeats = 0;
PickRandomFile.scanDirectories();
while (stopFlag == false && repeats != PickRandomFile.threadRepeatCount)
{
PickRandomFile.pickRandom();
Thread.Sleep(PickRandomFile.threadWaitDuration);
repeats++;
if (PickRandomFile.showStats)
{
String text = "";
//if its a repeat-until pick, show the number remaining.
if (PickRandomFile.threadRepeatCount != -1) { text += "R" + repeats.ToString() + "\\" + PickRandomFile.threadRepeatCount.ToString() + " "; }
//if its a shuffle, show the folder stats
if (PickRandomFile.shuffle) { text += "F" + PickRandomFile.allFiles.Count.ToString(); }
mainWindow.setStatText(text);
}
}
mainWindow.CloseMe();
}
#endregion
public static void StopThread()
{
stopFlag = true;
mainWindow.Close();
}
}
}