【问题标题】:Stop timer running a certain script?停止计时器运行某个脚本?
【发布时间】:2013-04-07 21:10:35
【问题描述】:

真的不知道如何正确地用这个词,所以请原谅糟糕的标题名称。

我正在使用计时器来检测我的 Xbox 上的按钮何时被按下。到目前为止它有效,但我用它在屏幕上打印文本。我需要它打印一次然后停止,在我关闭应用程序之前它会继续打印。

感谢任何帮助,

谢谢。

private void timer4_Tick(object sender, EventArgs e)
        {
            for (int i = 0; i <= 17; i++)
            {// all client? yes
                try
                {
                    uint LB = buttonpressed(i);

                    uint RB = buttonpressed(i); 
                    uint A = buttonpressed(i);
                    uint X = buttonpressed(i);
                    uint B = buttonpressed(i);
                    uint dpaddown = buttonpressed(i);
                    if (buttonpressed(0) == 0x4000)//Scrolling
                    {
                        scroll++;
                    }
                    else if (buttonpressed(0) == 0x8000)//Scrolling
                    {
                        scroll--;
                    }

                    if (MainMenu == 1 && scroll == 0)
                    {
                            Jtag.Call(0x82364E18, -1, 0, "v cg_chatHeight \"6\"");
                            Jtag.Call(0x82364E18, -1, 0, "v cg_chatTime \"60000\"");
                            Jtag.Call(0x82364E18, -1, 0, "v cg_hudsayposition \"250 250\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^4Option 1 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 2 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 3 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 4 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 5 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 6 Main Menu\"");
                    }
}
                catch
                {
                    MessageBox.Show("Error", "Not Connected");
                }
            }
        }


`

【问题讨论】:

    标签: c# xbox360


    【解决方案1】:

    使用Timer.Stop 方法。 您还可以通过将 Enabled 属性设置为 false 来停止计时器。

    http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.stop.aspx

    【讨论】:

    • 我知道我可以这样做,但我想添加更多内容,以便在屏幕上打印更多内容。所以,我真的不希望计时器停止,只是停止阅读那部分代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-19
    • 2018-02-04
    • 1970-01-01
    • 2021-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多