Esempio n. 1
0
        public bool RunModule()
        {
            if (!CheckModule(true, EModuleType.Module))
            {
                return(false);
            }

            try
            {
                Interlocked.Exchange(ref _LastRun, 0);

                Module m = (Module)_Current.Clone();
                m.Prepare(_Current);

                Thread th = _IO.CancelableThread = new Thread(new ParameterizedThreadStart(runModule));
                th.Name         = "RUN " + m.FullPath;
                th.IsBackground = true;
                th.Start(m);
                th.Join();

                //if (th.ThreadState == System.Threading.ThreadState.Aborted)
                //{
                //    // Check abort
                //    _IO.WriteError(Lang.Get("Aborting"));
                //}

                if (_LastRun == 1)
                {
                    return(true);
                }

                // Cancelado?
                if (_IO.CancelableThread != null)
                {
                    _Current.WriteError(Lang.Get("Run_Error"));
                }
            }
            catch (Exception e)
            {
                _Current.WriteError(e.Message);
            }
            finally
            {
                _IO.CancelableThread = null;
            }
            return(false);
        }