C#多线程扫描,在程序结束处出现异常!异常提示是“如何跨线程调用Windows窗体”!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
Thread[] thread;
public Form1()
{
InitializeComponent();
thread = new Thread[1];
for (int i = 0; i < 1; i++)//利用循环初始化10个线程
{
Thread t = new Thread(new ThreadStart(scan));
thread[i] = t;
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
int a, b, c, d;
string ipString;
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 1; i++)
{
thread[i].Start();
}
}
public bool isPortOpen(string ip)