目录
前言
基于相关文章总结
链接:Event-based Asynchronous Pattern Overview | Microsoft Docs
示例
// 自行脑补为Java即可
public class AsyncExample
{
// Synchronous methods.
public int Method1(string param);
public void Method2(double param);
// Asynchronous methods.
public void Method1Async(string param);
public void Method1Async(string param, object userState);
public event Method1CompletedEventHandler Method1Completed;
public void Method2Async(double param);
public void Method2Async(double param, object userState);
public event Method2CompletedEventHandler Method2Completed;
public void CancelAsync(object userState);
public bool IsBusy { get; }
// Class implementation not shown.
}
相关命名
ProgressPercentage:类名
ProgressChangedEventArgs:方法参数
UserState ProgressPercentage:ProgressChangedEventArgs属性
异步操作类型
单次异步操作
多次异步操作
多次异步操作区分标识
userState
多次异步操作完成标识
集合保存未完成userState