private void CheckTask()
        {
            if (!_task.IsComplete)
            {
                return;
            }

            if (_task.Exceptions != null && _task.Exceptions.Length != 0)
            {
                Logger.WriteLine("Exception(s) occurred, cannot load plugins");
                foreach (Exception ex in _task.Exceptions)
                {
                    Logger.WriteLine(ex.ToString());
                }
            }
            else
            {
                Logger.WriteLine("Finished task, loading plugins");
                _plugins = LoadPlugin();
                foreach (IPlugin plugin in _plugins)
                {
                    plugin.Init(MySandboxGame.Static);
                }
            }

            _data         = default(PluginData);
            _task         = default(ParallelTasks.Task);
            _downProgress = null;
        }
Example #2
0
        public DownloadProgress(ParallelTasks.Task task, Stats stats)
            : base(MyStringId.NullOrEmpty, null, beginAction, endAction)
        {
            Logger.WriteLine("entered");

            FriendlyName = typeof(DownloadProgress).Name;

            _instance       = this;
            _stats          = stats;
            _task           = new TaskWrapper(task);
            _timer          = new Timers.Timer(100d);
            _timer.Elapsed += Update;
            _timer.Start();
        }
Example #3
0
        public static void Register()
        {
            MyLog.Default.WriteLineAndConsole("TORCH MOD: Registering mod communication.");
            _outgoing    = new ConcurrentQueue <MessageBase>();
            _incoming    = new ConcurrentQueue <byte[]>();
            _playerCache = new List <IMyPlayer>();
            _lock        = new FastResourceLock();


            MyAPIGateway.Multiplayer.RegisterMessageHandler(NET_ID, MessageHandler);
            //background thread to handle de/compression and processing
            _task = MyAPIGateway.Parallel.StartBackground(DoProcessing);
            MyLog.Default.WriteLineAndConsole("TORCH MOD: Mod communication registered successfully.");
        }
        /// <summary>
        /// Creates an instance of <see cref="Loader"/> and, optionally, starts the updating process.
        /// </summary>
        /// <param name="update">Iff true, start the updating process.</param>
        public Loader(bool update)
        {
            if (_instance != null)
            {
                return;
            }

            _instance  = this;
            _directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            _data      = new PluginData(_directory);

            Logger.WriteLine(SeplShort + " version: " + new Version(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location), 0));

            _task = ParallelTasks.Parallel.StartBackground(() => Run(update));
        }
Example #5
0
        public virtual void Activate(Action callback = null)
        {
            if (!ActivationTask.IsComplete || m_isBeingAdded)
                return;
            MyHud.PushRotatingWheelVisible();
            m_isBeingAdded = true;
            ActivationTask = ParallelTasks.Parallel.Start(ActivateInternal, delegate()
            {
                if (m_visible)
                {
                    foreach (var grid in m_previewGrids)
                    {
                        MyEntities.Add(grid);
                        DisablePhysicsRecursively(grid);
                    }
                    if (callback != null)
                        callback();

                    IsActive = true;
                    m_isBeingAdded = false;
                }
                MyHud.PopRotatingWheelVisible();
            });
        }
Example #6
0
        public virtual void ActivateNoAlign(Action callback = null)
        {
            if (!ActivationTask.IsComplete || m_isBeingAdded)
                return;

            m_isBeingAdded = true;
            ActivationTask = ParallelTasks.Parallel.Start(delegate() { ChangeClipboardPreview(true); }, delegate()
            {
                if (m_visible)
                {
                    foreach (var grid in m_previewGrids)
                    {
                        MyEntities.Add(grid);
                        DisablePhysicsRecursively(grid);
                    }
                    if (callback != null)
                        callback();

                    IsActive = true;
                    m_isBeingAdded = false;
                }
            });
        }
Example #7
0
 public TaskWrapper(ParallelTasks.Task task)
 {
     _task = task;
 }
        public virtual void Activate(Action callback = null)
        {
            if (!ActivationTask.IsComplete)
                return;

            ActivationTask = ParallelTasks.Parallel.Start(ActivateInternal, delegate()
            {
                if (m_visible)
                {
                    foreach (var grid in m_previewGrids)
                    {
                        MyEntities.Add(grid);
                        DisablePhysicsRecursively(grid);
                    }
                    if (callback != null)
                        callback();

                    IsActive = true;
                }
            });
        }