//异步执行方法
private string doo(string a, string b, string c)
{
int i = 10, j = 0, k = 0;
try
{
WriteLog("执行doo", "test1");
k = i / j;
return "1";
}
catch (Exception ex)
{
WriteLog("执行doo Error:" + ex.Message, "test1");
return "-1";
}
}
protected void btnTest_Click(object sender, EventArgs e)
{
this.lbl_title.InnerHtml = "";
this.TextBox2.Text = "";
var del = new Func<string, string, string, string>(doo);
Task<string>.Factory.FromAsync(del.BeginInvoke, del.EndInvoke, "a1", "a2", "a3", null)
.ContinueWith(t =>
{
WriteLog(string.Format("\r\n执行doo的返回值:{0}", t.Result), "test2");
WriteLog(string.Format("\r\n执行doo的Over"), "test2");
});
WriteLog(string.Format("\r\ngo next"), "test");
ArrayList arrFriends = new ArrayList();
arrFriends.Add(1);
arrFriends.Add(200);
arrFriends.Add(30);
arrFriends.Sort();
string s = "";
Array.ForEach(arrFriends.ToArray(), i => s += (s != "" ? "," : "") + i);
WriteLog("\r\n结果:" + s, "test");
this.lbl_title.InnerHtml = s;
}