-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
115 lines (92 loc) · 3.98 KB
/
Program.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
namespace TorrentCrawler
{
internal static class Program
{
static public DebugForm debugForm { set; get; }
static public MainForm mainForm;
static public Thread threadsManager; // both not needed?
static private Thread formsManager;
static void Main()
{
threadsManager = Thread.CurrentThread;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// create Thread to run MainForm
Thread newThread = new Thread(() => Application.Run(new MainForm()));
newThread.Start();
formsManager = newThread;
Thread.Sleep(1000); //fishy
debug("This is the main thread with id: " + Thread.CurrentThread.ManagedThreadId + ". He spwaned the Thread responsible for the formWindows with id: "
+ formsManager.ManagedThreadId);
}
private delegate void logPrint (string str);
static public void debug(String s)
{
logPrint lP = new logPrint(debugForm.addDebugLog);
debugForm.Invoke(lP, s);
//debugForm.addDebugLog(s);
}
private delegate void mainArchiveProgressBarInit (object obj);
static public void archiveProgressBarInitialization(int maximum, int current)
{
MainForm.ArchiveProgressBarInitializationObject initObj = new MainForm.ArchiveProgressBarInitializationObject(maximum, current);
mainArchiveProgressBarInit init = new mainArchiveProgressBarInit(mainForm.initializeArchiveProgressBar);
mainForm.Invoke(init, initObj);
}
private delegate void mainArchiveProgressBarStep();
static public void archiveProgressBarStep()
{
mainArchiveProgressBarStep step = new mainArchiveProgressBarStep(mainForm.stepArchiveProgressBar);
mainForm.Invoke(step);
}
private delegate void mainBlocksCompleted(int i);
static public void blocksCompleted(int count)
{
mainBlocksCompleted completed = new mainBlocksCompleted(mainForm.setBlocksCompleted);
mainForm.Invoke(completed, count);
}
private delegate void mainTorrentsInserted(int i);
static public void torrentsInserted(int count)
{
mainTorrentsInserted inserted = new mainTorrentsInserted(mainForm.setInsertedFirstTime);
mainForm.Invoke(inserted, count);
}
private delegate void mainTorrentsUpdated(int i);
static public void torrentsUpdated(int count)
{
mainTorrentsUpdated updated = new mainTorrentsUpdated(mainForm.setUpdated);
mainForm.Invoke(updated, count);
}
private delegate void mainDidntRespond(int i);
static public void torrentsNotResponding(int count)
{
mainDidntRespond respond = new mainDidntRespond(mainForm.setNotResponding);
mainForm.Invoke(respond, count);
}
private delegate void mainTotalInspected(int i);
static public void totalInspected(int count)
{
mainTotalInspected inspected = new mainTotalInspected(mainForm.setTotalTorrents);
mainForm.Invoke(inspected, count);
}
private delegate void mainTimeUpdate(TimeSpan i);
static public void updateTimeRunning(TimeSpan time)
{
mainTimeUpdate timeUpdate = new mainTimeUpdate(mainForm.setTimeRunning);
mainForm.Invoke(timeUpdate, time);
}
private delegate int mainGetStartingBlockInput();
static public int getStartingBlockInput()
{
mainGetStartingBlockInput getStart = new mainGetStartingBlockInput(mainForm.startingBlockGetInput);
return (int) mainForm.Invoke(getStart);
}
}
}