gpt4 book ai didi

C# 线程 - resetThread 是 'variable' 但像 'method' 一样使用

转载 作者:太空宇宙 更新时间:2023-11-03 21:21:50 26 4
gpt4 key购买 nike

我正在尝试创建一个线程来重置我正在编写的应用程序中的按钮颜色,但是每当我尝试创建 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()。在类范围内不能有同名的方法和字段。

关于C# 线程 - resetThread 是 'variable' 但像 'method' 一样使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30186280/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com