⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asyncwebservice.cs

📁 《ASP.NET 2.0 XML 高级编程(第3版)》 《ASP.NET 2.0 XML 高级编程(第3版)》
💻 CS
字号:
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class AsyncWebService : System.Web.Services.WebService {

	public delegate string SleepForSpecificDurationAsyncStub(int milliseconds);

	public string SleepForSpecificDuration(int milliseconds)
	{
		System.Threading.Thread.Sleep(milliseconds);
		return "Completed";
	}

	public class WebServiceState
	{
		public object PreviousState;
		public SleepForSpecificDurationAsyncStub AsyncStub;
	}

	[WebMethod]
	public IAsyncResult BeginSleepForSpecificDuration(
		int milliseconds, AsyncCallback callback, object s)
	{
		SleepForSpecificDurationAsyncStub stub = new SleepForSpecificDurationAsyncStub(SleepForSpecificDuration);
		WebServiceState state = new WebServiceState();
		state.PreviousState = s;
		state.AsyncStub = stub;
		return stub.BeginInvoke(milliseconds, callback, state);
	}

	[System.Web.Services.WebMethod]
	public string EndSleepForSpecificDuration(IAsyncResult call)
	{
		WebServiceState state = (WebServiceState)call.AsyncState;
		return state.AsyncStub.EndInvoke(call);
	}    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -