コード例 #1
0
ファイル: AsyncTest.aspx.cs プロジェクト: Helen1987/edu
	protected void cmdSynchronous_Click(object sender, EventArgs e)
	{
		// Record the start time.
		DateTime startTime = DateTime.Now;

		// Get the web service data.
		EmployeesService proxy = new EmployeesService();
		try
		{
			GridView1.DataSource = proxy.GetEmployeesSlow();
		}
		catch (Exception err)
		{
			lblInfo.Text = "Problem contacting web service.";
			return;
		}

		GridView1.DataBind();

		// Perform some other time-consuming tasks.
		DoSomethingSlow();

		// Determine the total time taken.
		TimeSpan timeTaken = DateTime.Now.Subtract(startTime);
		lblInfo.Text = "Synchronous operations took " + timeTaken.TotalSeconds +
		  " seconds.";

	}