行动应在另一个行动完成后开始 [英] Action should start after the completion of another

查看:73
本文介绍了行动应在另一个行动完成后开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



任何人都可以请你给我一些想法,我想在图形模式中将一个圆圈从一个位置移动到另一个位置乞讨圈将在任何有效位置,然后我将搜索下一个位置。现在,当圆圈到达那个确切位置时,圆圈应该从开始位置逐渐开始移动到下一个位置。所以程序应该找到下一个位置,然后圆圈应该朝那个方向移动。



这个过程应无限重复..



任何想法或一段代码或教程请。



谢谢

Hi All,

anyone could please give me some idea about this, i want to move a circle from one location to another location in graphical mode, at the begging circle will be at any valid position then i will search next location. now circle should start movement from start position to next position gradually when it reaches to that exact location. so program should find the next location and then circle should move toward that.

and this process should be repeated infinitely..

any idea or piece of code or tutorial please.

thanks

推荐答案

不要使用两个计时器 - 单个计时器就够了。 br />
在计时器Tick事件处理程序中,确定圆圈是否已完成移动 - 如果有,则查找新位置,然后开始朝向它移动。如果还没有,请将它向前移一步。



如果查找新位置操作需要很长时间,请将代码移动到后台工作程序中线程,以便它不会影响正在移动圆圈的主UI线程,并在您开始向一个点移动时立即启动它以找到新位置。然后在任务完成时存储下一个目的地,并在圆圈到达当前目的地时使用它。



如果没有现有代码,我无法更明确,但是如果你将它视为两个独立的操作而不是一个操作,那么它可能会更容易解决。
Don't use two timers - a single timer will be enough.
In the timer Tick event handler, decide if the circle has completed moving - if it has, then look for a new location, and start it moving towards it. If it hasn't, move it a step closer.

If the "find a new location" operation takes a long time, then move the code into a background worker thread so that it doesn't impact the main UI thread that is moving the circle, and kick it off to find a new location as soon as you start the circle moving towards a point. You then store the next destination when the task completes, and use it when the circle reaches it's current destination.

Without you existing code, I can't be more explicit, but if you treat it as two separate operations rather than one followed by the other it will probably be easier to work out.


这篇关于行动应在另一个行动完成后开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆