本文介绍了主线程不运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这段代码C#来自在线源代码,但它在控制台应用程序中,所以我修改为在Windows窗体上工作只是为了学习如何使用threading.timer,但它不起作用。任何人都可以帮助我吗? 我希望下面的代码向richtextbox显示消息,而timer对象尚未销毁,因此主线程不应该运行。当计时器对象被销毁时,主线程将启动并显示最后一条消息,计时器示例完成。 任何人都可以告诉我为什么计时器没有'不执行CheckStatus(),因为在那个方法中有一些消息要显示,但我根本没有看到消息显示..提前感谢。 -------- -------------------------------------------------- ---------------------------------------This code C# is from online source but it was in console application so I modify to work on windows form just for learning on how to use threading.timer, but it doesn''t work. Can anyone help me?I would like the code below to display message to richtextbox while the timer object is not yet destroy so the main thread shouldn''t run. When timer object is destroy, the main thread will start and display the last message, "Timer example done."Can anyone tell me why the timer doesn''t execute CheckStatus() because in that method has some message to display, but I don''t see the message display at all.. Thanks in advance.------------------------------------------------------------------------------------------------- 展开 | 选择 | Wrap | Line数字推荐答案请记得使用COD发布时的E标签。 MODERATORPlease remember to use CODE tags when posting.MODERATOR谢谢,我也在寻找CODE Tage,但我不知道代码tage是Thanks, I was looking for the CODE tage too, but I didn''t know that code tage is我不确定Thread.Sleep(0)会做什么,但它可能意味着它会永远等待。您是否注意到您的程序停止工作?I am not sure what Thread.Sleep(0) would do, but it probably means it waits forever. Are you noticing your program just stops working? 这篇关于主线程不运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-21 11:37