📄 asyncwebservice.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 + -