我正在尝试创建一个线程来重置我正在编写的应用程序中的按钮颜色,但是每当我尝试创建 Thread 对象时,我都会收到错误消息“resetThread is a 'variable' but is used like a '方法'。这是我用来创建线程对象的代码:
System.Threading.Thread resetThread = new System.Threading.Thread(new System.Threading.ThreadStart(resetThread));
这是线程的代码:
public void resetThread()
{
while (true)
{
optionOne.BackColor = default(Color);
optionTwo.BackColor = default(Color);
optionThree.BackColor = default(Color);
System.Threading.Thread.Sleep(1000);
}
}
我该如何解决这个问题?提前致谢。我用谷歌搜索无济于事。
调用与方法不同的线程 - 例如调用方法 reset()
。在类范围内不能有同名的方法和字段。
我是一名优秀的程序员,十分优秀!