多线程里循环用易语言 延时 延迟还是延迟好

求教!!关于线程中循环的问题_vb吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:52,642贴子:
求教!!关于线程中循环的问题收藏
我做了一个子程序,在子程序中有for循环,循环体内有delay命令,然后用运行线程命令调用这个子程序,结果悲剧了,虽然我有跳出循环,但是似乎不起作用,当满足if条件时,exit for好像没起作用,因为delay一直在使程序延时,一直到延时结束,程序才继续运行。。。郁闷子程序代码大致是这样的:For...
For m = 1 To 100
If ... Then
.....额...格式被吞了,害我白白空格那么多次。。。
自己顶!求教啊!!!
If ... Then ...Exit ForEnd If“当满足if条件时”你确定?你通过什么判断IF满足了?如果不能100%确定,则在Exit For处设置“断点”当执行到Exit For语句时程序就会中断,若没有中断就说明没有执行Exit For,而不是Exit For不起作用。
别说你用的是按键精灵,那个好像没有断点功能,不过你可以在Exit For的上面加一句向调试窗口打印以确保的确执行了Exit For。
我if判断的是是否得到窗口句柄,而且确实得到了弹出窗口的句柄。但内循环就是不停止。。。if Hwnd then....exit ifdelay ...
我if判断的是是否得到窗口句柄,而且确实得到了弹出窗口的句柄。但内循环就是不停止。。。if Hwnd then....exit ifdelay ...
你用了2个for 你想退出哪个for next?
exit for 不是只能退出一个循环吗?作用跟C中的break一样不是吗?
exit for 不是只能退出一个循环吗?作用跟C中的break一样不是吗?老忘记回复。。。。。
只退一层循环
If Hwnd Then Msgbox "退出循环":Exit ForEnd If在Exit For前面加上这个去调试。
登录百度帐号我的游戏推荐游戏
后查看最近玩过的游戏
为兴趣而生,贴吧更懂你。或的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益你的位置: &&
重新想象 Windows 8 Store Apps (42) - 多线程之线程池: 延迟执行, 周期执行, 在线程池中找一个线程去执行指定的方法
重新想象 Windows 8 Store Apps (42) - 多线程之线程池: 延迟执行, 周期执行, 在线程池中找一个线程去执行指定的方法
介绍重新想象 Windows 8 Store Apps 之 线程池通过 ThreadPoolTimer 实现延迟执行通过 ThreadPoolTimer 实现周期执行通过 ThreadPool 实现“在线程池中找一个线程去执行指定的方法”示例1、通过 ThreadPoolTimer 实现延迟执行(ThreadPoolTimer 在 Windows.System.Threading 命名空间下)Thread/ThreadPool/DelayTimer.xaml&Page
x:Class="XamlDemo.Thread.ThreadPool.DelayTimer"
xmlns="/winfx/2006/xaml/presentation"
xmlns:x="/winfx/2006/xaml"
xmlns:local="using:XamlDemo.Thread.ThreadPool"
xmlns:d="/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"&
&Grid Background="Transparent"&
&StackPanel Margin="120 0 0 0"&
&TextBlock Name="lblMsg" FontSize="14.667" /&
&Button Name="btnCreateDelay" Content="延迟 3 秒后执行一个任务" Click="btnCreateDelay_Click_1" Margin="0 10 0 0" /&
&Button Name="btnCancelDelay" Content="取消任务" Click="btnCancelDelay_Click_1" Margin="0 10 0 0" /&
&/StackPanel&
&/Page&Thread/ThreadPool/DelayTimer.xaml.cs/*
* 通过 ThreadPoolTimer 实现延迟执行(ThreadPoolTimer 在 Windows.System.Threading 命名空间下)
* ThreadPoolTimer - 计时器
ThreadPoolTimer CreateTimer(TimerElapsedHandler handler, TimeSpan delay, TimerDestroyedHandler destroyed); - 创建一个用于延迟执行的计时器
handler - 指定的延迟时间过后,所需要执行的方法
delay - 延迟时间
destroyed - 当 ThreadPoolTimer 完成了自身的使命后所执行的方法(比如延迟方法执行完了或计时器被取消了)
Cancel() - 取消计时器
Delay - 延迟时间,只读
using Windows.UI.X
using Windows.UI.Xaml.C
using Windows.System.T
using Windows.UI.C
namespace XamlDemo.Thread.ThreadPool
public sealed partial class DelayTimer : Page
private ThreadPoolTimer _
public DelayTimer()
this.InitializeComponent();
// 创建一个延迟计时器
private void btnCreateDelay_Click_1(object sender, RoutedEventArgs e)
_timer = ThreadPoolTimer.CreateTimer(
(timer) =&
var ignored = Dispatcher.RunAsync(CoreDispatcherPriority.High,
lblMsg.Text = "任务执行了";
TimeSpan.FromSeconds(3),
(timer) =&
var ignored = Dispatcher.RunAsync(CoreDispatcherPriority.High,
lblMsg.Text += Environment.NewL
lblMsg.Text += "ThreadPoolTimer 的使命结束了";
lblMsg.Text = "延迟 3 秒后执行一个任务";
// 取消计时器
private void btnCancelDelay_Click_1(object sender, RoutedEventArgs e)
if (_timer != null)
_timer.Cancel();
lblMsg.Text += Environment.NewL
lblMsg.Text += "任务取消了";
}2、通过 ThreadPoolTimer 实现周期执行(ThreadPoolTimer 在 Windows.System.Threading 命名空间下)Thread/ThreadPool/PeriodicTimer.xaml&Page
x:Class="XamlDemo.Thread.ThreadPool.PeriodicTimer"
xmlns="/winfx/2006/xaml/presentation"
xmlns:x="/winfx/2006/xaml"
xmlns:local="using:XamlDemo.Thread.ThreadPool"
xmlns:d="/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"&
&Grid Background="Transparent"&
&StackPanel Margin="120 0 0 0"&
&TextBlock Name="lblMsg" FontSize="14.667" /&
&Button Name="btnCreatePeriodic" Content="执行一个周期任务" Click="btnCreatePeriodic_Click_1" Margin="0 10 0 0" /&
&Button Name="btnCancelPeriodic" Content="取消任务" Click="btnCancelPeriodic_Click_1" Margin="0 10 0 0" /&
&/StackPanel&
&/Page&Thread/ThreadPool/PeriodicTimer.xaml.cs/*
* 通过 ThreadPoolTimer 实现周期执行(ThreadPoolTimer 在 Windows.System.Threading 命名空间下)
* ThreadPoolTimer - 计时器
ThreadPoolTimer CreatePeriodicTimer(TimerElapsedHandler handler, TimeSpan period, TimerDestroyedHandler destroyed) - 创建一个用于延迟执行的计时器
handler - 每个周期时间点到达之后,所需要执行的方法
period - 周期执行的间隔时间
destroyed - 当 ThreadPoolTimer 完成了自身的使命后所执行的方法(比如计时器被取消了)
Cancel() - 取消计时器
Period - 间隔时间,只读
using Windows.System.T
using Windows.UI.C
using Windows.UI.X
using Windows.UI.Xaml.C
namespace XamlDemo.Thread.ThreadPool
public sealed partial class PeriodicTimer : Page
private ThreadPoolTimer _
private int _periodicTimerCount = 0;
public PeriodicTimer()
this.InitializeComponent();
// 创建一个周期计时器
private void btnCreatePeriodic_Click_1(object sender, RoutedEventArgs e)
_timer = ThreadPoolTimer.CreatePeriodicTimer(
(timer) =&
_periodicTimerCount++;
var ignored = Dispatcher.RunAsync(CoreDispatcherPriority.High,
lblMsg.Text = "任务执行次数:" + _periodicTimerCount.ToString();
// 第 1 次执行 handler 是在计时器被创建的 100 毫秒之后,然后每 100 毫秒执行一次 handler
// 计时器会保证每 100 毫秒调用一次 handler,而不管上一次 handler 是否已执行完
TimeSpan.FromMilliseconds(100),
(timer) =&
var ignored = Dispatcher.RunAsync(CoreDispatcherPriority.High,
lblMsg.Text += Environment.NewL
lblMsg.Text += "ThreadPoolTimer 的使命结束了";
lblMsg.Text = "任务执行次数:0";
// 取消计时器
private void btnCancelPeriodic_Click_1(object sender, RoutedEventArgs e)
if (_timer != null)
_timer.Cancel();
_periodicTimerCount = 0;
lblMsg.Text = "任务取消了";
}3、通过 ThreadPool 实现“在线程池中找一个线程去执行指定的方法”(ThreadPool 在 Windows.System.Threading 命名空间下)Thread/ThreadPool/WorkItem.xaml
&&作者:webabcd &&
最新热门tag

我要回帖

更多关于 淘宝延迟付款在哪里 的文章

 

随机推荐