当前位置:编程学习 > C#/ASP.NET >>

Remoting用Windows服务来部署时,暂停(OnPause)和继续(OnContinue)功能的困惑

最近把写完的Remoting服务器端 用windows服务来部署
要求是可以手动暂停服务,但是暂停后必须能继续保持客户端的相关信息,比如说登陆信息
就是说,即使windows服务被暂停了,但是仍然保存着客户的登陆信息,以便于继续执行服务时可以区别用户是否已经登陆
我的代码如下

public partial class FXPServerProcess : ServiceBase
    {
HttpChannel httpChannel = null;
        Thread th = null;   

        public FXPServerProcess()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            th = new Thread(new ThreadStart(ServiceThread));
            th.Start();   
        }
        protected void ServiceThread()
        {
            IDictionary properties = new Hashtable();
            properties.Add("port", 8888);//设定端口

            //ServerProvider
            SoapServerFormatterSinkProvider serverProvider = new SoapServerFormatterSinkProvider();

            serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            httpChannel = new HttpChannel(properties, null, serverProvider);
            ChannelServices.RegisterChannel(httpChannel, false);//注册通道
          
//Remoting
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(DealerRemotingService)
                    , "DealerRemotingService.rem", WellKnownObjectMode.Singleton);
        }

        protected override void OnStop()
        {
            try
            {
//服务开始
th.Abort();
                           }
            catch (Exception ex)
            {
            }
        }

        protected override void OnPause()
        {
            try
            {
//服务暂停,注销已经注册的HTTP通道
                IChannel ic = ChannelServices.GetChannel("http");
                ChannelServices.UnregisterChannel(ic);// 
            }
            catch (Exception ex)
            {
            }
        }

        protected override void OnContinue()
        {
            try
            {
//服务继续,重新注册HTTP通道
             ChannelServices.RegisterChannel(httpChannel, false);   
            }
            catch (Exception ex)
            {
                writer.WriteLog("OnContinue", "Server", ex.Message);
            }
        }

        protected override void OnShutdown()
        {
            try
            {
//服务停止
                th.Abort();
            }
            catch (Exception ex)
            {
            }
        }
    }


现在的问题是暂停功能好用,但是再次注册通道后,客户端就连结不上服务器了,总是提示连接不上Remoting服务器

有没有做过或者了解的朋友帮帮忙呀 --------------------编程问答-------------------- 没人知道吗?
在线等呀
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,