大家好,我收到一个例外if (checkBox1.IsChecked == true || checkBox2.IsChecked == true)
:
调用线程无法访问此对象,因为不同的线程拥有它。
在我的 wpf 应用程序中:
private void button1_Click(object sender, RoutedEventArgs e)
{
int i = 0;
int j = Int32.Parse(textBox1.Text);
thr = new Thread[j];
for (; i < j; i++)
{
thr[i] = new Thread(new ThreadStart(go));
thr[i].IsBackground = true;
thr[i].Start();
}
}
public void go()
{
while (true)
{
string acc = "";
string proxy = "";
if (checkBox1.IsChecked == true || checkBox2.IsChecked == true)
{
if (checkBox1.IsChecked == true)
Proxy.type = "http";
else if (checkBox2.IsChecked == true)
Proxy.type = "socks5";
else
Proxy.type = "none";
proxy = rand_proxy();
}
}
}
为什么?