コード例 #1
0
        public void IniciaThreadPrincipal()
        {
            try
            {
                VerificaThreadAtiva();

                controlePosicao = new ControlePosicao();
                webService = new WebServiceInfoPAE.WebServiceInfoPAE();
                webService.ControlePosicao = controlePosicao;

                controleModulo = new ControleModulo();
                listaModulos = controleModulo.getListaModulos();

                threadAtivada = true;

                threadPrincipal = new Thread(new ThreadStart(ProcessaThread));
                threadPrincipal.IsBackground = true;
                threadPrincipal.Start();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        private void VerificaThreadAtiva()
        {
            try
            {
                if (this.threadPrincipal != null && this.threadPrincipal.IsAlive)
                {

                    try
                    {
                        this.webService = null;
                        this.threadPrincipal.Abort();
                        this.threadPrincipal = null;
                    }
                    catch
                    {
                        this.threadPrincipal = null;
                    }

                }
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível verificar se a thread principal esta ativa. Erro: " + ex.Message);
            }
        }