Example #1
0
        /// <summary>
        /// Loader is finished
        /// </summary>
        protected virtual void LoaderFinished()
        {
            #region INLINES
            void Finished()
            {
                this.State = netLoaderState.Finished;

                try
                {
                    // never ever change order of event invokes!
                    OnLoadFinished?.Invoke(this);
                    CallbackObserver?.OnLoadFinished(this);
                }
                catch (Exception ex)
                {
                    // this is only the exception handling for the event invoke not for the loader itself!
                    Debug.WriteLine(ex);
                    // ToDo: logging interface
                }
            };
            #endregion

            if (this.State.HasFlag(netLoaderState.Canceled) || this.State.HasFlag(netLoaderState.CancelRequested))
            {
                LoaderCanceled(_cancelTokenSource.Token);
            }
            else
            {
                Finished();
            }
        }
        public new void Hide()
        {
            m_callback?.Invoke(null);

            isVisible  = false;
            m_callback = null;
        }
 public void LoadAsync(string contentManagerName, OnLoadFinished onFinish)
 {
     if (!mHasFinished)
     {
         mContentManagerName = contentManagerName;
         mThreaded           = true;
         mOnFinish           = onFinish;
         ThreadStart start = new ThreadStart(Load);
         mLoadThread = new Thread(start);
         mLoadThread.Start();
     }
 }
        void OnLoad()
        {
            VehicleEffectsDefinition definition = null;

            try
            {
                var textReader    = new StringReader(m_textField.text.Trim());
                var xmlSerializer = new XmlSerializer(typeof(VehicleEffectsDefinition));
                definition = (VehicleEffectsDefinition)xmlSerializer.Deserialize(textReader);
            }
            catch (Exception e)
            {
                UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Error parsing definition", e.Message + "\r\n" + e.StackTrace, true);
                Logging.LogException(e);
                return;
            }

            m_callback?.Invoke(definition);
            m_callback = null;
            Hide();
        }
 public void Show(OnLoadFinished callback = null)
 {
     Show(true);
     m_callback = callback;
 }