我想将我的线程配置为后台线程,为什么我的线程中缺少此属性?
ThreadStart starter = delegate { openAdapterForStatistics(_device); };
new Thread(starter).Start();
public void openAdapterForStatistics(PacketDevice selectedOutputDevice)
{
using (PacketCommunicator statCommunicator = selectedOutputDevice.Open(100, PacketDeviceOpenAttributes.Promiscuous, 1000)) //open the output adapter
{
statCommunicator.Mode = PacketCommunicatorMode.Statistics; //put the interface in statstics mode
statCommunicator.ReceiveStatistics(0, statisticsHandler);
}
}
我试过:
Thread thread = new Thread(openAdapterForStatistics(_device));
但我有 2 个编译错误:
- 'System.Threading.Thread.Thread(System.Threading.ThreadStart)' 的最佳重载方法匹配有一些无效参数
- 参数 1:无法从 'void' 转换为 'System.Threading.ThreadStart'
我不知道为什么