Func<string, string> f = new Func<string, string>(this.DownFileNWD);
AsyncCallback callback = delegate(IAsyncResult ar)
{
//没有完成不结束此线程
if (!ar.IsCompleted) return;
//强制转换传入对象为委托对象
Func<string, string> ff = (Func<string, string>)ar.AsyncState;
//执行结束返回结果
string path = ff.EndInvoke(ar);
if (!string.IsNullOrEmpty(path))
{
Action<string> action = new Action<string>(this.TryOpenFile);
action.BeginInvoke(path, new AsyncCallback(delegate(IAsyncResult ar2)
{
if (!ar2.IsCompleted) return;
Action<string> action2 = (Action<string>)ar2.AsyncState;
action2.EndInvoke(ar2);
}), action);
}
};
//开始执行
f.BeginInvoke(downloadUrl, callback, f);
UI现场异步处理
最新推荐文章于 2024-07-11 10:49:40 发布