回答編集履歴
2
サンプルコード追加
test
CHANGED
@@ -43,3 +43,99 @@
|
|
43
43
|
}
|
44
44
|
|
45
45
|
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
追記
|
52
|
+
|
53
|
+
```C#
|
54
|
+
|
55
|
+
using System;
|
56
|
+
|
57
|
+
using System.Collections.Generic;
|
58
|
+
|
59
|
+
using System.Threading.Tasks;
|
60
|
+
|
61
|
+
using System.Windows.Forms;
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
namespace Test
|
66
|
+
|
67
|
+
{
|
68
|
+
|
69
|
+
class Form1 : Form
|
70
|
+
|
71
|
+
{
|
72
|
+
|
73
|
+
static void Main(string[] args)
|
74
|
+
|
75
|
+
{
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
var runningTask = new List<Task>();
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
foreach(string arg in args)
|
84
|
+
|
85
|
+
{
|
86
|
+
|
87
|
+
runningTask.Add(Task.Run(() =>
|
88
|
+
|
89
|
+
{
|
90
|
+
|
91
|
+
Application.Run(new Form1(arg));
|
92
|
+
|
93
|
+
}));
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
foreach(var t in runningTask)
|
100
|
+
|
101
|
+
{
|
102
|
+
|
103
|
+
t.Wait();
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
private TextBox textBox1;
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
public Form1(string file)
|
116
|
+
|
117
|
+
{
|
118
|
+
|
119
|
+
this.textBox1 = new System.Windows.Forms.TextBox();
|
120
|
+
|
121
|
+
this.textBox1.Location = new System.Drawing.Point(10, 10);
|
122
|
+
|
123
|
+
this.textBox1.Size = new System.Drawing.Size(150, 20);
|
124
|
+
|
125
|
+
this.textBox1.Text = file;
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
this.ClientSize = new System.Drawing.Size(200, 50);
|
130
|
+
|
131
|
+
this.Controls.Add(this.textBox1);
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
```
|
1
コピペミス修正
test
CHANGED
@@ -1,19 +1,3 @@
|
|
1
|
-
Taskが別スレッドで動作するのはご存知と思います。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
別スレッドで動作するということは、Mainスレッドをブロックしないということです。
|
6
|
-
|
7
|
-
Mainメソッドが終了すると、Mainスレッドが終了し、アプリケーションが終了してしまいます。
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Task.Waitメソッドなどでタスクの終了を待機してください。
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
```C#
|
16
|
-
|
17
1
|
Taskが別スレッドで動作するのはご存知と思います。
|
18
2
|
|
19
3
|
|
@@ -59,5 +43,3 @@
|
|
59
43
|
}
|
60
44
|
|
61
45
|
```
|
62
|
-
|
63
|
-
```
|