Ejemplo n.º 1
0
        static void ConnectToWCF()
        {
            try
            {
                proxy = new localhost.PokeInWCF();
                bool b;
                proxy.PingAlive(out b, out b);

                ServerConnected = true;

                /* ConnectToWCF method call
                 * made by static constructor or CheckMessage function?
                 *
                 * Check, if there is an existing worker thread
                 */
                if (workerThread == null)
                {
                    workerThread = new System.Threading.Thread(CheckMessages);
                    workerThread.Start();
                }

                CometWorker.SendToAll("UpdateServiceStatus(" + ServerConnected.ToString().ToLower() + ");");

                string[] clientIds = CometWorker.GetClientIds();
                if (clientIds != null)
                {
                    proxy.AddClients(clientIds);
                }
            }
            catch
            {
                //Connection Issue re-try after 1.5 secs
                Thread.Sleep(1500);
                ConnectToWCF();
            }
        }