代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace picture_0
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Thread th;
private void Form1_Load(object sender, EventArgs e)
{
th = new Thread
(
delegate ()
{
for (int i = ; i < ; i++)
{
ChangeImage(Image.FromFile(@"picture\\18720223738\_6b6c58f282\_o.jpg"), );
ChangeImage(Image.FromFile(@"picture\\amargosa-river-stars.jpg"), );
}
}
);
th.IsBackground = true;
th.Start();
}
private void Form1\_FormClosed(object sender, FormClosedEventArgs e)
{
th.Abort();//结束线程
}
private void ChangeImage(Image img, int millisecondsTimeOut)
{
this.Invoke(new Action(() =>
{
pictureBox1.Image = img;
})
);
Thread.Sleep(millisecondsTimeOut);
}
}
}
代码
手机扫一扫
移动阅读更方便
你可能感兴趣的文章