C#多线程操作GIF

来源:百度知道 编辑:UC知道 时间:2024/06/09 06:07:00
在导入数据的时候由于数据量大会卡住所以觉得用个GIF做效果,但GIF出来了不动,有操作代码的贴出来,谢谢,我对多线程不熟悉
不行啊,调用操作的时候出现 线程间操作无效: 从不是创建控件“”的线程访问它。

一个大概的思路,点下Button1后,开一个子线程去处理数据,同时在界面上显示一个等待图片,子线程处理完后把图片隐藏掉就可以了,比如:
private void button1_Click(object sender, EventArgs e)
{
pictureBox1.ImageLocation = "Wait.gif";
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(SubProcess));
t.Start();
}

void SubProcess()
{
...
处理你的数据
...
pictureBox1.ImageLocation = null;
}