/// <summary>
        /// Performs a test to check whether the master container
        /// is active on the given uri.
        /// </summary>
        /// <param name="state">An instance of <see cref="T:System.Uri"/>
        /// representing the unique resource identifier of the container.</param>
        private ProbeResult ProbeWorker(Uri state)
        {
            ProbeResult outcome = null;
            Uri workerUri = state;
            try
            {
                string ip = workerUri.Host;
                if (workerUri.HostNameType == UriHostNameType.Dns)
                {
                    ip = NetworkUtil.GetIPByHostName(workerUri.Host);
                }
                bool bActive = NetworkUtil.Ping(ip);
                if (bActive == true)
                {
                    bActive = NetworkUtil.Probe(ip, workerUri.Port);
                    if (bActive == true)
                    {
                        outcome = ProbeContainer(workerUri.OriginalString);
                    }
                    else
                    {
                        outcome = new ProbeResult(workerUri.OriginalString, ProbeStatus.ServiceUnactive);
                    }
                }
                else
                {
                    outcome = new ProbeResult(workerUri.OriginalString, ProbeStatus.NetworkUnreachable);
                }
            }
            catch (Exception ex)
            {
                outcome = new ProbeResult(workerUri.OriginalString, ProbeStatus.Error, ex);
                return outcome;
            }

            if (outcome == null)
            {
                outcome = new ProbeResult(workerUri.Host, ProbeStatus.ServiceActive);
            }
            //try
            //{
            //    this.Invoke(new ProbeUpdater(this.UpdateMasterUI), new object[] { outcome });
            //}
            //catch (Exception ex)
            //{
            //    // if the dialog is closing and the thread is trying to update
            //    // the user interface we have an exception, we then wrap it and
            //    // everything should be fine...
            //}
            return outcome;
        }
        /// <summary>
        /// Probes a <paramref name="uri"/> to see whether there is
        /// container active there.
        /// </summary>
        /// <param name="uri">A <see langword="string"/> containing the 
        /// unique reosurce identifier of a possible remote container.
        /// </param>
        /// <returns>A <see cref="T:Aneka.UI.Configuration.ProbeResult"/> specifing the
        /// result of the probe operation.</returns>
        protected ProbeResult ProbeContainer(string uri)
        {
            ProbeResult result = null;
            try
            {
                ProbeQueryMessage probe = new ProbeQueryMessage("");
                Message msg = MessageDispatcher.SendMessage(new Uri(uri), probe);
                ProbeReplyMessage reply = msg as ProbeReplyMessage;

                Exception inner = null;

                if (reply == null)
                {
                    ErrorMessage error = msg as ErrorMessage;
                    if (error != null)
                    {
                        inner = error.Cause;
                    }
                    else
                    {
                        string errMsg = string.Format("Invalid response to probe: " + msg.GetType().FullName);
                        inner = new Exception(errMsg);
                        inner.Data.Add("message", msg);
                    }

                }

                result = new ProbeResult(uri, ProbeStatus.ServiceActive, inner);
            }
            catch (Exception ex)
            {

                // [CV] NOTE: we already know that the port is active if we call
                //            this method, hence it might be another service.
                result = new ProbeResult(uri, ProbeStatus.ServiceUnknown, ex);
            }

            return result;
        }
        /// <summary>
        /// Refresh Worker Status
        /// </summary>
        /// <param name="WorkerID">Worker ID</param>
        /// <returns>Worker Status</returns>
        public ProbeResult RefreshWorker(int WorkerID)
        {
            Worker worker = db.Workers.Find(WorkerID);
            Cloud cloud = cloudLookupFromWorkerId(WorkerID);
            CloudWebPortal.Areas.Aneka.Models.Machine machine = machineLookupFromWorkerId(WorkerID);

            ProbeResult result = new ProbeResult(GetContainerUri(machine.IP, worker.Port), ProbeStatus.Error);

            Uri workerUri = null;
            string container = null;

            try
            {
                if (machine == null || worker.AnekaContainerID == null)
                    return result;

                container = GetContainerUri(machine.IP, worker.Port);
                workerUri = new Uri(container);

                // [CV] NOTE: we are now sure that everything is at least
                //            feasible for starting asynchronous probing.
                result = ProbeWorker(workerUri);

            }
            catch (Exception ex)
            {
                result = new ProbeResult(container, ProbeStatus.Error, ex);
            }
            finally
            {
                worker.StatusEnum = result.Status;
                if (result.Status == ProbeStatus.ServiceActive)
                    worker.isInstalled = true;
                db.SaveChanges();
            }

            return result;
        }