为什么计时器不能在全屏模式下工作?

发布于 2024-11-13 10:42:55 字数 628 浏览 2 评论 0原文

我有一个带有计时器的Windows窗体应用程序。

每当我打开游戏等全屏应用程序并尝试调试计时器时,它都会完全忽略它。但是当我将应用程序更改为窗口模式时,调试就开始工作了。

我还尝试按一个键(使用全局挂钩)并调试单击,并且在我在游戏中(全屏)时调试工作正常。

有人遇到过这个问题吗?如何解决?

编辑:似乎即使这样也不会进入调试(从 Form1() 调用 OpenNewTempThread)

private void OpenNewTempThread()
    {
        Thread thread = new Thread(Temp) { Name = "TempThread" };
        thread.Start();
    }

    private bool Temping = true;
    private void Temp()
    {
        while (true)
        {
            while (Temping)
            {
                Thread.Sleep(5000);
            }
            Thread.Sleep(100);
        }
    }

I got a windows form application with a timer.

Whenever I open a fullscreen application like a game and try to debug the timer, it completely ignores it. But the second I change the application to window mode, the debugging works.

I also tried pressing a key (using global hook) and debugging the click and the debugging worked while I was in the game (full screen).

Has anyone ever had this issue? how can it be fixed?

EDIT : It seems that even this doesn't go into debug (Called OpenNewTempThread from Form1())

private void OpenNewTempThread()
    {
        Thread thread = new Thread(Temp) { Name = "TempThread" };
        thread.Start();
    }

    private bool Temping = true;
    private void Temp()
    {
        while (true)
        {
            while (Temping)
            {
                Thread.Sleep(5000);
            }
            Thread.Sleep(100);
        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离笑几人歌 2024-11-20 10:42:55

尝试将此行放入您的代码中(假设您在调试器下运行,它将起作用):

System.Diagnostics.Debugger.Break();

Try putting this line in your code (it'll work assuming you are running under a debugger):

System.Diagnostics.Debugger.Break();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文