委託挺不錯,最近需要,委託來下載圖片!!記錄下

using System;
using System.Collections.Generic;
using System.Web;
using YTBtb.Bll;
using System.Runtime.Remoting.Messaging;

namespace YTBtb.Web
{
    public class HandelHelper
    {
        public delegate void AddHandler(List<Infomations> infos, string path);
        static void DownLoadImg(List<Infomations> infos, string path)
        {
            foreach (var info in infos)
            {
                if (info.PicturePath != null && info.PicturePath != "")
                {
                    string newPic = info.PicturePath;
                    ImgHelper.SaveInfoPic(info, path, ref newPic);
                }
            }

        }

        static void AddComplete(IAsyncResult result)
        {
            AddHandler handler = (AddHandler)((AsyncResult)result).AsyncDelegate;
            handler.EndInvoke(result);
        }

        public HandelHelper(List<Infomations> infos, string path)
        {
            AddHandler handler = new AddHandler(DownLoadImg);
            IAsyncResult result = handler.BeginInvoke(infos, path, new AsyncCallback(AddComplete), "AsycState:OK");
        }
    }
}


發佈了16 篇原創文章 · 獲贊 4 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章