using LocalService;
public partial class WSTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
/**//// <summary>
/// 事件驱动的异步模式的异步
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void EventDriveButton_Click(object sender, EventArgs e)
{
Response.Write("事件驱动的异步模式的异步 <BR>");
LocalService.WebService localService = new LocalService.WebService(); //创建代理类对象。
localService.HelloWorldCompleted += new LocalService.HelloWorldCompletedEventHandler((o, a) => { Response.Write(string.Format("完成时间:{0}。 结果{1}<Br>", DateTime.Now.ToString("mm:ss.ffff"), a.Result)); });//创建事件。写结果与运行事件
Response.Write(string.Format("开始调用时间:{0}<Br>", DateTime.Now.ToString("mm:ss.ffff")));//开始调用事件
localService.HelloWorldAsync();//异步调用
Response.Write(string.Format("调用结束时间:{0}<Br>", DateTime.Now.ToString("mm:ss.ffff")));
Thread.Sleep(4000);//等待异步操作完成
}
}
应该是自动生成代理类的命名空间吧