日期:2014-05-17 浏览次数:20824 次
//监听按键信息
System.Threading.Timer threadTimer;
/// <summary>
/// 开启监听
/// </summary>
private void StartListen()
{
threadTimer = new System.Threading.Timer(new TimerCallback(CatchTelNumber), null, 1000, 500);
listerner.AuthenticationSchemes = AuthenticationSchemes.Anonymous;//指定身份验证 Anonymous匿名访问
listerner.Prefixes.Add("http://localhost:4529/login/");
listerner.Start();
}
/// <summary>
/// 获取按键信息
/// </summary>
/// <param name="state"></param>
private void CatchTelNumber(object state)
{
_th = new Thread(new ThreadStart(() =>
{
//等待请求连接
//没有请求则GetContext处于阻塞状态
lock (_lock)
{
HttpListenerContext ctx = listerner.GetContext();