该属性已经设置,不能修改。
在 System.Threading.Thread.set_Name(String value)
出现这种异常的原因:重复给线程的Name属性赋值
using System.Threading;
public void Test()
{
try
{
Thread thread = new Thread(() => { });
thread.Name = "SubThread";
thread.Name = "SubThread";
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Test();