C#picturebox导致整个表格冻结并永远加载

时间:2013-04-30 05:04:21

标签: c# picturebox

我不确定发生了什么,但每当我尝试从不同的线程动态加载图像时,它将导致我的整个表单只是冻结并永远加载。以下是我的称呼方式:

新线程将使用图像路径调用此方法,例如newimages \ 0.jpg

public void setImage(String imgPath)
        {
            Bitmap bmp = new Bitmap(imgPath);
            screenshotBox.InvokeEx(a => a.Image = bmp);
        }

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace Server
{
    static class ISynchronizeInvokeExtensions
    {
        public static void InvokeEx<T>(this T @this, Action<T> action) where T : ISynchronizeInvoke
        {
            if (@this.InvokeRequired)
            {
                @this.Invoke(action, new object[] { @this });
            }
            else
            {
                action(@this);
            }
        }
    }
}

0 个答案:

没有答案
相关问题