异步我这么写对吗?
本帖最后由 shimin555 于 2013-09-09 15:28:48 编辑
public delegate void AsyncEventHandler();
public WindowMenu()
{
InitializeComponent();
AsyncEventHandler asy = new AsyncEventHandler(LoadImage);
asy.BeginInvoke(new AsyncCallback(CallbackMethod), asy);
}
void LoadImage()
{
}
void CallbackMethod(IAsyncResult ar)
{
((AsyncEventHandler)ar.AsyncState).EndInvoke(ar);
}
为啥到 AsyncEventHandler asy = new AsyncEventHandler(LoadImage);直接跳出去了
------解决方案--------------------何为直接跳出去了?
------解决方案--------------------简单点就用Action吧
Action act=LoadImage;
act.BeginInvoke(new AsyncCallback(CallbackMethod), act);
不用定义delegate了
------解决方案--------------------参考异步专题:http://www.cnblogs.com/zhili/category/475336.html