Beispiel #1
0
        public void run()
        {
            while(true)
            {
                ResolveEntry r;
                Ice.Instrumentation.ThreadObserver threadObserver;

                lock(this)
                {
                    while(!_destroyed && _queue.Count == 0)
                    {
                        System.Threading.Monitor.Wait(this);
                    }

                    if(_destroyed)
                    {
                        break;
                    }

                    r = _queue.First.Value;
                    _queue.RemoveFirst();
                    threadObserver = _observer;
                }

                if(threadObserver != null)
                {
                    threadObserver.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateIdle,
                                                Ice.Instrumentation.ThreadState.ThreadStateInUseForOther);
                }

                try
                {

                    NetworkProxy networkProxy = _instance.networkProxy();
                    int protocol = _protocol;
                    if(networkProxy != null)
                    {
                        networkProxy = networkProxy.resolveHost(protocol);
                        if(networkProxy != null)
                        {
                            protocol = networkProxy.getProtocolSupport();
                        }
                    }

                    r.callback.connectors(r.endpoint.connectors(Network.getAddresses(r.host,
                                                                                     r.port,
                                                                                     protocol,
                                                                                     r.selType,
                                                                                     _preferIPv6,
                                                                                     true),
                                                                networkProxy));
                }
                catch(Ice.LocalException ex)
                {
                    if(r.observer != null)
                    {
                        r.observer.failed(ex.ice_id());
                    }
                    r.callback.exception(ex);
                }
                finally
                {
                    if(threadObserver != null)
                    {
                        threadObserver.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateInUseForOther,
                                                    Ice.Instrumentation.ThreadState.ThreadStateIdle);
                    }
                    if(r.observer != null)
                    {
                        r.observer.detach();
                    }
                }
            }

            foreach(ResolveEntry entry in _queue)
            {
                Ice.CommunicatorDestroyedException ex = new Ice.CommunicatorDestroyedException();
                if(entry.observer != null)
                {
                    entry.observer.failed(ex.ice_id());
                    entry.observer.detach();
                }
                entry.callback.exception(ex);
            }
            _queue.Clear();

            if(_observer != null)
            {
                _observer.detach();
            }
        }
        public void run()
        {
            while (true)
            {
                ResolveEntry r;
                Ice.Instrumentation.ThreadObserver threadObserver;

                lock (this)
                {
                    while (!_destroyed && _queue.Count == 0)
                    {
                        Monitor.Wait(this);
                    }

                    if (_destroyed)
                    {
                        break;
                    }

                    r = _queue.First.Value;
                    _queue.RemoveFirst();
                    threadObserver = _observer;
                }

                if (threadObserver != null)
                {
                    threadObserver.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateIdle,
                                                Ice.Instrumentation.ThreadState.ThreadStateInUseForOther);
                }

                try
                {
                    NetworkProxy networkProxy = _instance.networkProxy();
                    int          protocol     = _protocol;
                    if (networkProxy != null)
                    {
                        networkProxy = networkProxy.resolveHost(protocol);
                        if (networkProxy != null)
                        {
                            protocol = networkProxy.getProtocolSupport();
                        }
                    }

                    List <EndPoint> addrs = Network.getAddresses(r.host, r.port, protocol, r.selType, _preferIPv6, true);
                    if (r.observer != null)
                    {
                        r.observer.detach();
                        r.observer = null;
                    }

                    r.callback.connectors(r.endpoint.connectors(addrs, networkProxy));
                }
                catch (Ice.LocalException ex)
                {
                    if (r.observer != null)
                    {
                        r.observer.failed(ex.ice_id());
                        r.observer.detach();
                    }
                    r.callback.exception(ex);
                }
                finally
                {
                    if (threadObserver != null)
                    {
                        threadObserver.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateInUseForOther,
                                                    Ice.Instrumentation.ThreadState.ThreadStateIdle);
                    }
                }
            }

            foreach (ResolveEntry entry in _queue)
            {
                Ice.CommunicatorDestroyedException ex = new Ice.CommunicatorDestroyedException();
                if (entry.observer != null)
                {
                    entry.observer.failed(ex.ice_id());
                    entry.observer.detach();
                }
                entry.callback.exception(ex);
            }
            _queue.Clear();

            if (_observer != null)
            {
                _observer.detach();
            }
        }
        public void run()
        {
            while(true)
            {
                ResolveEntry r;
                Ice.Instrumentation.ThreadObserver threadObserver;

                _m.Lock();
                try
                {
                    while(!_destroyed && _queue.Count == 0)
                    {
                        _m.Wait();
                    }

                    if(_destroyed)
                    {
                        break;
                    }

                    r = _queue.First.Value;
                    _queue.RemoveFirst();
                    threadObserver = _observer;
                }
                finally
                {
                    _m.Unlock();
                }

                try
                {
                    if(threadObserver != null)
                    {
                        threadObserver.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateIdle, 
                                                    Ice.Instrumentation.ThreadState.ThreadStateInUseForOther);
                    }

                    r.callback.connectors(r.endpoint.connectors(Network.getAddresses(r.host, 
                                                                                     r.port, 
                                                                                     _protocol, 
                                                                                     r.selType, 
                                                                                     _preferIPv6, 
                                                                                     true)));

                    if(threadObserver != null)
                    {
                        threadObserver.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateInUseForOther, 
                                                    Ice.Instrumentation.ThreadState.ThreadStateIdle);
                    }
                }
                catch(Ice.LocalException ex)
                {
                    if(r.observer != null)
                    {
                        r.observer.failed(ex.ice_name());
                    }
                    r.callback.exception(ex);
                }
                finally
                {
                    if(r.observer != null)
                    {
                        r.observer.detach();
                    }
                }
            }

            foreach(ResolveEntry entry in _queue)
            {
                Ice.CommunicatorDestroyedException ex = new Ice.CommunicatorDestroyedException();
                entry.callback.exception(ex);
                if(entry.observer != null)
                {
                    entry.observer.failed(ex.ice_name());
                    entry.observer.detach();
                }
            }
            _queue.Clear();

            if(_observer != null)
            {
                _observer.detach();
            }
        }