Thread.sleep()方法在C# [英] Thread.Sleep() in C#

查看:159
本文介绍了Thread.sleep()方法在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C#中视觉&NBSP图像浏览;一室  2010 其中显示图像逐一秒后:

I want to make an image viewer in C# Visual Studio 2010 which displays images one by one after seconds:

i = 0;

if (image1.Length > 0) //image1 is an array string containing the images directory
{
    while (i < image1.Length)
    {
        pictureBox1.Image = System.Drawing.Image.FromFile(image1[i]);
        i++;
        System.Threading.Thread.Sleep(2000);
    }

在程序启动,停止,只是表明我的第一个和最后一个图像

When the program starts, it stops and just shows me the first and last image.

推荐答案

Thread.sleep代码块你的UI线程使用的 System.Windows.Forms.Timer 来代替。

Thread.Sleep blocks your UI thread use System.Windows.Forms.Timer instead.

这篇关于Thread.sleep()方法在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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