質問編集履歴
4
ソースの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,6 +40,10 @@
|
|
40
40
|
|
41
41
|
System.Windows.Forms.Timer timer2 = new System.Windows.Forms.Timer();
|
42
42
|
|
43
|
+
loop1(Main_loop);
|
44
|
+
|
45
|
+
loop2(sabu_loop);
|
46
|
+
|
43
47
|
public Form1()
|
44
48
|
|
45
49
|
{
|
@@ -62,11 +66,11 @@
|
|
62
66
|
|
63
67
|
|
64
68
|
|
65
|
-
|
69
|
+
//タイマー開始
|
66
70
|
|
67
|
-
|
71
|
+
timer1.Enabled = true;
|
68
72
|
|
69
|
-
|
73
|
+
timer2.Enabled = true;
|
70
74
|
|
71
75
|
}
|
72
76
|
|
@@ -100,7 +104,7 @@
|
|
100
104
|
|
101
105
|
timer1.Interval = 1000;
|
102
106
|
|
103
|
-
timer1.Enabled =
|
107
|
+
timer1.Enabled = false;
|
104
108
|
|
105
109
|
|
106
110
|
|
@@ -118,7 +122,7 @@
|
|
118
122
|
|
119
123
|
timer2.Interval = intVal * 60000;
|
120
124
|
|
121
|
-
timer2.Enabled =
|
125
|
+
timer2.Enabled = false;
|
122
126
|
|
123
127
|
}
|
124
128
|
|
3
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,8 +52,6 @@
|
|
52
52
|
|
53
53
|
}
|
54
54
|
|
55
|
-
//メイン処理
|
56
|
-
|
57
55
|
public void button1_Click(object sender, EventArgs e)
|
58
56
|
|
59
57
|
{
|
@@ -81,10 +79,6 @@
|
|
81
79
|
timer1.Enabled = false;
|
82
80
|
|
83
81
|
timer2.Enabled = false;
|
84
|
-
|
85
|
-
label1.Text = "\n停止";
|
86
|
-
|
87
|
-
label1.Refresh();
|
88
82
|
|
89
83
|
//ボタンを戻す
|
90
84
|
|
2
ソースの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,13 +32,19 @@
|
|
32
32
|
|
33
33
|
```C#
|
34
34
|
|
35
|
+
public partial class Form1 : Form
|
36
|
+
|
37
|
+
{
|
38
|
+
|
39
|
+
System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
|
40
|
+
|
41
|
+
System.Windows.Forms.Timer timer2 = new System.Windows.Forms.Timer();
|
42
|
+
|
35
|
-
public Form1()
|
43
|
+
public Form1()
|
36
44
|
|
37
45
|
{
|
38
46
|
|
39
47
|
InitializeComponent();
|
40
|
-
|
41
|
-
//開始時は開始ボタン(button1)はtrue 停止ボタン(button2)はfalse
|
42
48
|
|
43
49
|
button1.Enabled = true;
|
44
50
|
|
@@ -46,21 +52,21 @@
|
|
46
52
|
|
47
53
|
}
|
48
54
|
|
49
|
-
|
55
|
+
//メイン処理
|
50
56
|
|
51
57
|
public void button1_Click(object sender, EventArgs e)
|
52
58
|
|
53
59
|
{
|
54
60
|
|
55
|
-
//button1をクリック時に開始ボタン(button1)はfalse 停止ボタン(button2)はtrueに変更
|
56
|
-
|
57
61
|
button1.Enabled = false;
|
58
62
|
|
59
63
|
button2.Enabled = true;
|
60
64
|
|
61
|
-
|
65
|
+
|
62
66
|
|
63
|
-
loop(Main_loop);
|
67
|
+
loop1(Main_loop);
|
68
|
+
|
69
|
+
loop2(sabu_loop);
|
64
70
|
|
65
71
|
|
66
72
|
|
@@ -70,29 +76,55 @@
|
|
70
76
|
|
71
77
|
{
|
72
78
|
|
73
|
-
//
|
79
|
+
//タイマーの停止
|
74
80
|
|
81
|
+
timer1.Enabled = false;
|
82
|
+
|
83
|
+
timer2.Enabled = false;
|
84
|
+
|
85
|
+
label1.Text = "\n停止";
|
86
|
+
|
87
|
+
label1.Refresh();
|
88
|
+
|
89
|
+
//ボタンを戻す
|
90
|
+
|
91
|
+
button1.Enabled = true;
|
92
|
+
|
93
|
+
button2.Enabled = false;
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
//3秒ごとに動くタイマー
|
100
|
+
|
101
|
+
public void loop1(EventHandler eventHandler)
|
102
|
+
|
103
|
+
{
|
104
|
+
|
75
|
-
|
105
|
+
timer1.Tick += new EventHandler(eventHandler);
|
106
|
+
|
107
|
+
timer1.Interval = 1000;
|
108
|
+
|
109
|
+
timer1.Enabled = true;
|
110
|
+
|
111
|
+
|
76
112
|
|
77
113
|
}
|
78
114
|
|
79
115
|
//numericUpDown1 * 60秒 でループするタイマー
|
80
116
|
|
81
|
-
public void loop(EventHandler eventHandler)
|
117
|
+
public void loop2(EventHandler eventHandler)
|
82
118
|
|
83
119
|
{
|
84
120
|
|
85
121
|
int intVal = Decimal.ToInt32(numericUpDown1.Value);
|
86
122
|
|
87
|
-
|
123
|
+
timer2.Tick += new EventHandler(eventHandler);
|
88
124
|
|
89
|
-
timer.
|
125
|
+
timer2.Interval = intVal * 60000;
|
90
126
|
|
91
|
-
timer.Interval = intVal * 60000;
|
92
|
-
|
93
|
-
timer.Enabled = true;
|
127
|
+
timer2.Enabled = true;
|
94
|
-
|
95
|
-
//timer.Start();
|
96
128
|
|
97
129
|
}
|
98
130
|
|
@@ -100,21 +132,21 @@
|
|
100
132
|
|
101
133
|
{
|
102
134
|
|
103
|
-
|
135
|
+
//メイン処理
|
104
136
|
|
137
|
+
}
|
138
|
+
|
139
|
+
void sabu_loop(object sender, EventArgs e)
|
140
|
+
|
141
|
+
{
|
142
|
+
|
105
|
-
|
143
|
+
//サブ処理
|
144
|
+
|
145
|
+
}
|
106
146
|
|
107
147
|
|
108
148
|
|
109
|
-
|
149
|
+
}
|
110
|
-
|
111
|
-
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
|
112
|
-
|
113
|
-
{
|
114
|
-
|
115
|
-
Application.Exit();
|
116
|
-
|
117
|
-
}
|
118
150
|
|
119
151
|
}
|
120
152
|
|
1
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,21 +38,27 @@
|
|
38
38
|
|
39
39
|
InitializeComponent();
|
40
40
|
|
41
|
+
//開始時は開始ボタン(button1)はtrue 停止ボタン(button2)はfalse
|
42
|
+
|
41
43
|
button1.Enabled = true;
|
42
44
|
|
43
45
|
button2.Enabled = false;
|
44
46
|
|
45
47
|
}
|
46
48
|
|
47
|
-
|
49
|
+
|
48
50
|
|
49
51
|
public void button1_Click(object sender, EventArgs e)
|
50
52
|
|
51
53
|
{
|
52
54
|
|
55
|
+
//button1をクリック時に開始ボタン(button1)はfalse 停止ボタン(button2)はtrueに変更
|
56
|
+
|
53
57
|
button1.Enabled = false;
|
54
58
|
|
55
59
|
button2.Enabled = true;
|
60
|
+
|
61
|
+
//(Main_loop)を一定間隔(loop)ごとに実行する
|
56
62
|
|
57
63
|
loop(Main_loop);
|
58
64
|
|