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

📄 sessionrefreshthread.cs

📁 ICE3.3.0--聊天程序服务器端demo
💻 CS
字号:
// **********************************************************************
//
// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
//
// This copy of Chat Demo is licensed to you under the terms
// described in the CHAT_DEMO_LICENSE file included in this
// distribution.
//
// **********************************************************************

using System;
using System.Threading;
using System.Windows.Threading;

namespace ChatDemoGUI
{
    //
    // This class is responsible for refreshing maintaing the
    // Glacier2 session. Instead of extending IceUtil::Thread, we
    // launch it using the ThreadStart facility.
    //
    public class SessionRefreshThread
    {
        public SessionRefreshThread(Chat.ChatSessionPrx session, long period)
        {
            this._done = false;
            this._session = session;
            this._period = period;
            _coordinator = ((App)System.Windows.Application.Current).getCoordinator();
        }

        public void run()
        {
            lock(this)
            {
                do
                {
                    try
                    {
                        _session.ice_ping();
                    }
                    catch(Ice.LocalException ex)
                    {
                    _coordinator.setError("<system-message> - The connection with the server was unexpectedly lost.\n" + ex.ToString() +
                         "\nYou can try login again from the File menu.");
                        _done = true;
                    }
                    if(!_done)
                    {
                        Monitor.Wait(this, (int)_period);
                    }
                } 
                while(!_done);
            }
        }

        public void done()
        {
            lock(this)
            {
                if(!_done)
                {
                    _done = true;
                    Monitor.PulseAll(this);
                }
            }
        }

        private Boolean _done = false;
        private Chat.ChatSessionPrx _session = null;
        private long _period;
        private Coordinator _coordinator = null;
    }
}

⌨️ 快捷键说明

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