C# 如何中止线程Tcp连接
我开始了解我成功使用的线程,但我不能中止线程 程序无法成功结束 请帮助我如何中止C# 如何中止线程Tcp连接,c#,multithreading,C#,Multithreading,我开始了解我成功使用的线程,但我不能中止线程 程序无法成功结束 请帮助我如何中止 for (int i = 0; i < dtProd.Rows.Count; i++) { sayacno = dtProd.Rows[i].ItemArray[2].ToString(); komut = "<25></25>"; Connection TCP =
for (int i = 0; i < dtProd.Rows.Count; i++)
{
sayacno = dtProd.Rows[i].ItemArray[2].ToString();
komut = "<25></25>";
Connection TCP = new Connection("as","sd","fd","gd");
Thread t = new Thread(new ThreadStart(TCP.Bagla));
t.IsBackground = true;
t.Start();
threads.Add(t);
Thread.Sleep(100);
}
for (int t = 0; t < threads.Count; t++)
{
try
{
threads[t].Join();
threads[t].Abort();
}
catch (ThreadAbortException tx)
{
Console.Write(tx.ToString());
}
}
for(int i=0;i
我想您已经更改了以下呼叫:
threads[t].Join();
threads[t].Abort();
致:
threads[t].Join()
将导致调用线程阻塞,直到线程[t]
线程结束。我不希望它能到达中止线。
threads[t].Abort();
threads[t].Join();