C# TableLayoutPanel MouseMove 太多 CPU

发布于 2024-08-22 16:44:47 字数 779 浏览 3 评论 0原文

问候。我对以下代码有疑问。由于某种原因,每当它执行时,它都会消耗大约 60% 的 CPU。这很奇怪,想知道您是否有什么意见?

    private void HomeTableLayoutPanel_MouseMove(object sender, MouseEventArgs e)
    {

        PictureBox HomeCurrentPicBox = (PictureBox)(HomeTableLayoutPanel.GetChildAtPoint(e.Location));
        TableLayoutPanelCellPosition HomeCurrentPosition = new TableLayoutPanelCellPosition(-1, -1);

        if (HomeCurrentPicBox != null)
        {
            HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
            gameFormToolTip.SetToolTip(HomeTableLayoutPanel, GameModel.alphaCoords(HomeCurrentPosition.Column) + "," + HomeCurrentPosition.Row.ToString());
        }
    }

谢谢您的宝贵时间。

编辑:我告诉它采样太频繁了。在某些方面,我的其他半工作代码也是如此。但我的问题太长了,我无法解释。 :(

greetings. i have an issue with the following code. for some reason whenever it is executed it is consuming around 60% of the CPU. this is strange, and was wondering if you had any comments?

    private void HomeTableLayoutPanel_MouseMove(object sender, MouseEventArgs e)
    {

        PictureBox HomeCurrentPicBox = (PictureBox)(HomeTableLayoutPanel.GetChildAtPoint(e.Location));
        TableLayoutPanelCellPosition HomeCurrentPosition = new TableLayoutPanelCellPosition(-1, -1);

        if (HomeCurrentPicBox != null)
        {
            HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
            gameFormToolTip.SetToolTip(HomeTableLayoutPanel, GameModel.alphaCoords(HomeCurrentPosition.Column) + "," + HomeCurrentPosition.Row.ToString());
        }
    }

thank you for your time.

edit: im told it is sampling too often. in some aspects this is true in my other semi working code. but my question is too lengthy and i cant explain it. :(

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

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

发布评论

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

评论(1

淡淡離愁欲言轉身 2024-08-29 16:44:47

你不能只附加到(每个?)PictureBox 的 mousemove 事件吗?

can't you just attach to the mousemove event of the (each?) PictureBox?

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