首页 \ 问答 \ 等待没有睡觉?(Waiting without Sleeping?)

等待没有睡觉?(Waiting without Sleeping?)

我想要做的是启动一个函数,然后将bool更改为false,等待一秒钟并再次将其变为true。 但是我想在没有等待功能的情况下这样做,我该怎么做?

我只能使用Visual C#2010 Express。

这是有问题的代码。 我正在尝试接收用户输入(例如右箭头)并相应地移动,但在角色移动时不允许进一步输入。

        x = Test.Location.X;
        y = Test.Location.Y;
        if (direction == "right") 
        {
            for (int i = 0; i < 32; i++)
            {
                x++;
                Test.Location = new Point(x, y);
                Thread.Sleep(31);
            }
        }
    }

    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        int xmax = Screen.PrimaryScreen.Bounds.Width - 32;
        int ymax = Screen.PrimaryScreen.Bounds.Height - 32;
        if (e.KeyCode == Keys.Right && x < xmax) direction = "right";
        else if (e.KeyCode == Keys.Left && x > 0) direction = "left";
        else if (e.KeyCode == Keys.Up && y > 0) direction = "up";
        else if (e.KeyCode == Keys.Down && y < ymax) direction = "down";

        if (moveAllowed)
        {
            moveAllowed = false;
            Movement();
        }
        moveAllowed = true;  
    }

What I'm trying to do is start a function, then change a bool to false, wait a second and turn it to true again. However I'd like to do it without the function having to wait, how do I do this?

I can only use Visual C# 2010 Express.

This is the problematic code. I am trying receive user input (right arrow for example) and move accordingly, but not allow further input while the character is moving.

        x = Test.Location.X;
        y = Test.Location.Y;
        if (direction == "right") 
        {
            for (int i = 0; i < 32; i++)
            {
                x++;
                Test.Location = new Point(x, y);
                Thread.Sleep(31);
            }
        }
    }

    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        int xmax = Screen.PrimaryScreen.Bounds.Width - 32;
        int ymax = Screen.PrimaryScreen.Bounds.Height - 32;
        if (e.KeyCode == Keys.Right && x < xmax) direction = "right";
        else if (e.KeyCode == Keys.Left && x > 0) direction = "left";
        else if (e.KeyCode == Keys.Up && y > 0) direction = "up";
        else if (e.KeyCode == Keys.Down && y < ymax) direction = "down";

        if (moveAllowed)
        {
            moveAllowed = false;
            Movement();
        }
        moveAllowed = true;  
    }

原文:https://stackoverflow.com/questions/30826490
更新时间:2023-11-07 19:11

最满意答案

虽然ServiceStack不支持旧版本,但您可以返回ServiceStack提交日志,直到看到INCR到v3.9.x的消息。

快速浏览版本的一种方法是查看对Properties / Assembly.cs文件的更改,该文件在版本递增时会发生更改。

由于ServiceStack使用来自不同子项目的组件,因此您需要对ServiceStack.TextServiceStack.OrmLiteServiceStack.Redis执行相同的操作。

ServiceStack保持相同的版本与其他组件同步,因此ServiceStack的v3.9.4使用v3.9.4的ServiceStack.Text等。


Although older versions are not supported by ServiceStack, you could to go back through the ServiceStack commit logs until you see a message that says INCR to v3.9.x.

One way to quickly browse releases is to look at changes to the Properties/Assembly.cs file which changes when the version is incremented.

As ServiceStack is uses components from different sub projects, you will need to do the same for ServiceStack.Text, ServiceStack.OrmLite and ServiceStack.Redis as well.

ServiceStack keeps the same version in-sync with the other components, so the v3.9.4 of ServiceStack uses a v3.9.4 of ServiceStack.Text, etc.

相关问答

更多
  • 希望您从此处设置发布配置: 同时转到Configuration Manager并将Active Solution Configuration检查为Release。 Hope you have set the Release configuration from here: Also go to the Configuration Manager and check the Active Solution Configuration as Release.
  • 堆栈溢出表示您的堆栈空间不足(可能很明显,但以防万一)。 典型的原因是非终止或过度递归,或非常大的堆栈对象重复。 有趣的是它可能就是这种情况。 很可能在Release中你的编译器正在进行尾调用优化,这可以防止堆栈溢出过多的递归。 也许在Release中你的编译器正在从lineParser优化向量的返回副本。 所以你需要找出Debug中溢出的条件,我会以递归作为最可能的罪魁祸首,尝试将字符串参数类型更改为引用,即。 void BSTIndex::addWord(BSTIndexNode *& pCurrent ...
  • 堆栈是一组服务。 这与组合文件如何定义一组要运行的容器类似。 所以如果你只需要运行一个服务,你可以通过docker service create 。 如果您需要部署一组服务,或者使用撰写文件中的定义作为您的服务定义,那么您可以使用docker stack deploy部署它们。 A stack is a collection of services. This is similar to how a compose file defines a group of containers to run. So ...
  • 这是完全正常的,您的Release版程序启用了抖动优化器。 阅读此答案 ,了解它所执行的优化方式。 您的Program.ConvertToInt()方法成为该列表中第一个项目符号的受害者。 它内联了 。 内联是一种非常基本的优化策略,而不是发出一个CALL来调用该方法,优化器注入了该方法的代码。 对于不生成大量机器代码的小方法,会发生这种情况。 这是一个重要的优化,它可以避免设置调用堆栈并进行分支,它可以轻松地节省一些纳秒。 并且使更多优化可用,包括但不限于如果优化器可以确定特定参数使得运行代码不必要,则使 ...
  • 在这种情况下,也许module.wait与使用unless特性的cmd.run一起使用。 您需要一种很好的方法来检查服务是否未安装,并在除非测试中使用它。 命令本身可能就像echo一样 - 这并不重要。 您现在可以使用watch或watch_in来使module.wait依赖于cmd.run 。 未经测试的草稿 (注意我根本不知道windows cli): check_if_service_installed: cmd.run: name: echo 'not installed' un ...
  • ServiceStack包含白名单,因此默认情况下只提供具有众所周知扩展名的文件。 您可以通过在AppHost.Configure()中添加.swf添加.swf到白名单: SetConfig(new EndpointHostConfig { AllowFileExtensions = { {"swf"} }, }); ServiceStack includes a whitelist so only files with well known extensions get served by de ...
  • 虽然ServiceStack不支持旧版本,但您可以返回ServiceStack提交日志,直到看到INCR到v3.9.x的消息。 快速浏览版本的一种方法是查看对Properties / Assembly.cs文件的更改,该文件在版本递增时会发生更改。 由于ServiceStack使用来自不同子项目的组件,因此您需要对ServiceStack.Text , ServiceStack.OrmLite和ServiceStack.Redis执行相同的操作。 ServiceStack保持相同的版本与其他组件同步,因此S ...
  • 我收到了Demis Bellot关于Service Stack G +社区的回复。 官方许可证包含官方NuGet包,而AGPL / FOSS异常许可证涵盖GitHub上的源代码,并列在SS repos的根目录中,例如: https : //github.com/ServiceStack/ServiceStack/斑点/主/ LICENSE.TXT#L40 v4的所有源代码都在GitHub上,开源项目可以构建自己的分支,并使用测试许可证密钥: https : //github.com/ServiceStack ...
  • 您可以在版本名称中包含版本定义名称。 You could include the release definition name in the release name.
  • 到目前为止,我们不支持VSO中的标准环境,并且从错误消息(这是错误的)开始,看起来您正试图在标准环境中运行发布。 最近,我们阻止了新标准环境的创建,但尚未触及现有的标准环境。 您能否尝试在VNext天蓝色环境中运行发布并分享它是否适合您? We are not supporting standard environments in VSO as of now and from the error message (which is bad), it looks like you are trying to ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。