Beispiel #1
0
        public void Loop(float deltaTime)
        {
            IsSucess = mThreadIsSucess;
            Error    = mThreadError;
            Progress = mThreadProgress;
            IsDone   = mThreadIsDone;

            if (!IsDone)
            {
                mUseTime = mUseTime + deltaTime;
                if (mUseTime >= mTimeout || !string.IsNullOrEmpty(Error))
                {
                    IsDone   = true;
                    IsSucess = false;
                    Error    = "下载超时: + \n其他异常:" + Error;
                }
            }
            try
            {
                OnLoading?.Invoke(this);
                if (IsDone)
                {
                    OnLoaded?.Invoke(this);
                }
            }
            catch (Exception e)
            {
                App.Error(e);
            }
            if (IsDone)
            {
                Close();
            }
        }
Beispiel #2
0
        public virtual void Load(IEnumerable <string> output)
        {
            ETLTargetAdapterEventArgs e = new ETLTargetAdapterEventArgs()
            {
                TargetSpecification = TargetSpecification
            };

            OnTargetAdapterStart?.Invoke(this, e);
            using (BlockingCollection <string> bc = new BlockingCollection <string>())
            {
                using (Task t = Task.Factory.StartNew(() =>
                                                      LoadOutput(bc.GetConsumingEnumerable()),
                                                      TaskCreationOptions.AttachedToParent & TaskCreationOptions.LongRunning))
                {
                    foreach (var item in output)
                    {
                        e.Output = item;
                        OnLoading?.Invoke(this, e);
                        bc.Add(e.Output);
                        e.Counter++;
                        OnLoaded?.Invoke(this, e);
                    }
                    bc.CompleteAdding();
                    t.Wait();
                }
            }
            if (TargetValidator != null)
            {
                e.IsValid = TargetValidator.Validate(TargetSpecification);
            }
            OnTargetAdapterEnd?.Invoke(this, e);
        }
Beispiel #3
0
        private void RegistAssembly(Assembly assembly)
        {
            List <TypeInfo> controllers = new List <TypeInfo>();
            Type            PluginType  = typeof(IPluginStartup);

            foreach (var typeInfo in assembly.DefinedTypes)
            {
                if (typeInfo.IsAbstract || typeInfo.IsInterface)
                {
                    continue;
                }

                if (IsController(typeInfo) && !controllers.Contains(typeInfo))
                {
                    controllers.Add(typeInfo);
                }
                else if (PluginType.IsAssignableFrom(typeInfo.AsType()))
                {
                    var plugin = (Activator.CreateInstance(typeInfo.AsType()) as IPluginStartup);
                    plugin.ConfigureServices(Builder.ServiceCollection);
                    OnLoading?.Invoke(plugin);
                }
            }
            if (controllers.Count > 0 && !ActionDescriptorProvider.PluginControllers.ContainsKey(assembly.FullName))
            {
                controllers.ForEach(c => Builder.ServiceCollection.TryAddTransient(c.AsType()));
                ActionDescriptorProvider.PluginControllers.Add(assembly.FullName, controllers);
            }
        }
Beispiel #4
0
        private IEnumerator Start()
        {
            IsLoading = true;
            OnLoading?.Invoke(this, IsLoading);
            yield return(null);

            for (var i = 0; i < SceneManager.sceneCount; i++)
            {
                if (i == _myIndex)
                {
                    continue;
                }
                SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(i));
                yield return(null);
            }
            _scene = SceneManager.LoadSceneAsync(_nextScene, LoadSceneMode.Additive);
            if (_preventActivation)
            {
                _scene.allowSceneActivation = false;
            }
            yield return(new WaitForSeconds(loadTime));

            _scene.allowSceneActivation = true;
            if (_scene.isDone)
            {
                StartCoroutine(GameReady());
            }
            else
            {
                _scene.completed += operation => StartCoroutine(GameReady());
            }
        }
        public IEnumerator Load(string id, Transform parent = null)
        {
            OnLoading?.Invoke(LoadingEventType.LoadingStart);

            if (!m_loadedStadiumModels.TryGetValue(id, out GameObject stadium))
            {
                Progress = 0;
                var handle = Addressables.InstantiateAsync(id, parent);

                while (!handle.IsDone)
                {
                    Progress = handle.PercentComplete;
                    OnLoading?.Invoke(LoadingEventType.LoadingProgressChange);
                    yield return(null);
                }

                Progress = 1;

                if (handle.Status != AsyncOperationStatus.Succeeded)
                {
                    OnLoading?.Invoke(LoadingEventType.LoadingFailed);
                    throw new NullReferenceException("Failed to load prefab : " + id);
                }
                else
                {
                    stadium = handle.Result;
                    m_loadedStadiumModels.Add(id, stadium);
                }
            }

            if (!stadium)
            {
                throw new NullReferenceException("Game object not found in prefab : " + id);
            }
            else
            {
                // Disable up existing model
                if (m_stadiumLook)
                {
                    var oldStadium = m_stadiumLook.gameObject;
                    oldStadium.SetActive(false);
                }

                stadium.SetActive(true);
                m_stadiumLook             = stadium.GetComponent <StadiumLook>();
                m_extrasProfileController = stadium.GetComponent <ExtrasProfileController>();
                m_crowdManager            = stadium.GetComponent <CrowdManager>();
            }

            SetSurfaceType(MatchSurface);
            SetBillboard1(AdBillboard1);
            SetBillboard2(AdBillboard2);
            SetSeatColor(SeatColor);
            SetExtrasProfile(ExtrasProfileIndex);
            SetCrowdSize(CrowdSize);
            m_crowdManager?.SetMatchSimulationManager(m_matchSimulationManager);

            OnLoading?.Invoke(LoadingEventType.LoadingDone);
        }
Beispiel #6
0
        private IEnumerator GameReady()
        {
            yield return(null);

            SceneManager.UnloadSceneAsync(_myIndex);
            IsLoading = false;
            OnLoading?.Invoke(this, IsLoading);
        }
        /// <summary>
        /// 获取任务状态信息
        /// </summary>
        private void GetTaskStatus()
        {
            try
            {
                //复制key
                List <string> keyList = new List <string>();
                foreach (var key in downLoadDict.Keys)
                {
                    keyList.Add(key);
                }


                //遍历查询状态
                foreach (var gid in keyList)
                {
                    try
                    {
                        Aria2cTask task = TellStatus(gid);
                        if (task == null)
                        {
                            //当一个任务出问题,则本次循环就放弃掉.例如被杀掉进程后,要是还循环获取状态,是始终拿不到状态的.
                            break;
                        }
                        if (downLoadDict[gid].Status != task.Status)
                        {
                            OnStatusChanged(task);
                        }

                        if (task.Status == Aria2cTaskStatus.Active)
                        {
                            OnLoading?.Invoke(this, new Aria2cTaskEvent(task));
                        }

                        UpdateDownTask(task);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Beispiel #8
0
 internal void init_loading_progress(string url)
 {
     if (url != null)
     {
         Log.Write("Downloading:" + url);
     }
     show_progress(100, 0);
     if (url != null)
     {
         delay(url);
         if (Visible && OnLoading != null)
         {
             OnLoading.Invoke("URL:" + url);
         }
     }
     web_routine_status = WebRoutineStatus.UNDEFINED;
 }
        protected virtual async Task LoadData(string q)
        {
            searchText  = q;
            current_url = URL;
            await OnLoading.InvokeAsync(true);

            var response = await _api.GetCustom <IEnumerable <T> >($"{URL}{(URL.IndexOf('?') > 0 ? "&" : "?")}limit={Limit}&q={q}");

            if (response.Status == 200 && response.Data != null)
            {
                await OnSearchData.InvokeAsync(response.Data);
            }
            else
            {
                await OnSearchData.InvokeAsync(new List <T>());
            }
            await OnLoading.InvokeAsync(false);
        }
Beispiel #10
0
        protected override void EndProcessing()
        {
            var page = new Page();

            page.Name            = Name;
            page.Url             = Url;
            page.Icon            = FontAwesomeIconsExtensions.GetIconName(Icon);
            page.Id              = Id;
            page.DefaultHomePage = DefaultHomePage;
            page.AutoRefresh     = AutoRefresh;
            page.RefreshInterval = RefreshInterval;
            page.Title           = Title;
            page.Properties      = MyInvocation.BoundParameters;
            page.Blank           = Blank;
            page.Loading         = OnLoading?.Invoke();

            try
            {
                if (Url != null && !Url.StartsWith("/"))
                {
                    Url = "/" + Url;
                }

                if (Url == null && Name != null)
                {
                    page.Url = "/" + Name.Replace(' ', '-');
                }

                page.Name            = Name;
                page.Callback        = Content.GenerateCallback(Id, this, SessionState, ArgumentList);
                page.Callback.IsPage = true;
                page.Callback.Page   = page;
                page.Dynamic         = true;
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.SyntaxError, page));
                page.Error = new Error(ex);
            }

            Log.Debug(JsonConvert.SerializeObject(page));

            WriteObject(page);
        }
Beispiel #11
0
        public void Loop(float lastDuration)
        {
            IsSucess = mThreadIsSucess;
            Error    = mThreadError;
            Progress = mThreadProgress;
            IsDone   = mThreadIsDone;

            //mUseTime = MathUtil.Clamp(mUseTime + lastDuration, 0, mTimeout);
            //if (mUseTime == mTimeout)
            //{
            //    IsDone = true; // 这里没有直接给isDone赋值是为了防止多线程操作出现不同步, 这样缓一帧在完成保证线程操作的同步性
            //    IsSucess = false;
            //    Error = "下载超时: + \n其他异常:" + Error;
            //}
            OnLoading?.Invoke(this);
            if (IsDone)
            {
                OnLoaded?.Invoke(this);
            }
        }
        private void RegistAssembly(Assembly assembly)
        {
            List <TypeInfo> controllers = new List <TypeInfo>();
            Type            PluginType  = typeof(IPluginStartup);

            foreach (var typeInfo in assembly.DefinedTypes)
            {
                if (typeInfo.IsAbstract || typeInfo.IsInterface)
                {
                    continue;
                }

                if (IsController(typeInfo) && !controllers.Contains(typeInfo))
                {
                    controllers.Add(typeInfo);
                }
                else if (PluginType.IsAssignableFrom(typeInfo.AsType()))
                {
                    var plugin = (Activator.CreateInstance(typeInfo.AsType()) as IPluginStartup);
                    plugin.CurrentPluginPath = Path.GetDirectoryName(assembly.Location);
                    var binIndex = plugin.CurrentPluginPath.IndexOf("\\bin\\");
                    if (binIndex >= 0)
                    {
                        plugin.CurrentPluginPath = plugin.CurrentPluginPath.Substring(0, binIndex);
                    }
                    if (Services != null)
                    {
                        plugin.HostingEnvironment = HostingEnvironment;
                        plugin.ConfigureServices(Services());
                    }
                    OnLoading?.Invoke(plugin);
                }
            }
            if (controllers.Count > 0 && !ActionDescriptorProvider.PluginControllers.ContainsKey(assembly.FullName) && Services != null)
            {
                IServiceCollection services = Services();
                controllers.Each(c => services.TryAddTransient(c.AsType()));
                ActionDescriptorProvider.PluginControllers.Add(assembly.FullName, controllers);
            }
        }
Beispiel #13
0
        public IEnumerator Load(string id, Transform parent = null)
        {
            OnLoading?.Invoke(LoadingEventType.LoadingStart);

            if (!m_loadedPlayerModels.TryGetValue(id, out GameObject player))
            {
                Progress = 0;
                var handle = Addressables.InstantiateAsync(id, parent.position, parent.rotation);

                while (!handle.IsDone)
                {
                    Progress = handle.PercentComplete;
                    OnLoading?.Invoke(LoadingEventType.LoadingProgressChange);
                    yield return(null);
                }

                Progress = 1;

                if (handle.Status != AsyncOperationStatus.Succeeded)
                {
                    OnLoading?.Invoke(LoadingEventType.LoadingFailed);

                    throw new NullReferenceException("Failed to load prefab : " + id);
                }
                else
                {
                    player = handle.Result;
                    m_loadedPlayerModels.Add(id, player);
                }
            }


            if (!player)
            {
                throw new NullReferenceException("Game object not found in prefab : " + id);
            }
            else
            {
                // Disable existing model
                if (m_playerLook)
                {
                    var oldPlayer = m_playerLook.gameObject;
                    oldPlayer.SetActive(false);
                }

                player.SetActive(true);
                m_playerView = player.GetComponent <TennisPlayerView>();
                m_playerLook = player.GetComponent <PlayerLook>();

                if (m_playerView && m_racket)
                {
                    m_playerView.SetRacket(m_racket.transform);
                    m_playerView.SetShotPoint(m_racket.ShotPoint);
                }

                if (m_playerLook)
                {
                    m_playerLook.SetRootPath(RootAssetPath);
                    m_playerLook.RacketRenderer = m_racket?.RacketRenderer;
                }

                var ikInterpolation = player.GetComponent <IKInterpolation>();
                if (ikInterpolation && m_racket)
                {
                    ikInterpolation.LeftHandTarget  = m_racket.LeftHandIKTarget;
                    ikInterpolation.RightHandTarget = m_racket.RightHandIKTarget;
                }
            }

            if (m_matchData != null)
            {
                m_playerView?.Initialize(m_matchData.MatchPlayer, m_matchData.ReverseDisplay, m_signalBus, m_matchSimulationManager);
                m_playerLook?.InitializeLook(m_matchData.PlayerLookData, m_matchData.TechData, m_matchData.OutfitData, m_matchData.ShoesData);
            }
            else
            {
                m_playerLook?.SetGender((int)Gender);
                m_playerLook?.SetSkin(SkinType);
                SetHairdo(Hairdo);
                m_playerLook?.SetCoiffure(Hairdo, HairColor);
                m_playerLook?.SetWristbands((int)Wristbands, AccessoryColor);
                m_playerView?.UpdateHandedness(Handedness == Handedness.LeftHanded);
            }

            OnLoading?.Invoke(LoadingEventType.LoadingDone);
        }
Beispiel #14
0
 public void Load() => OnLoading?.Invoke();
Beispiel #15
0
 public void NotifyLoading(Event eventArgs)
 {
     OnLoading?.Invoke(this, eventArgs);
 }
Beispiel #16
0
 protected internal void RaiseLoading(object sender, PluginLoadingEventArgs e)
 => OnLoading?.Invoke(sender, e);
 private void Awake()
 {
     _currentIndex = SceneManager.GetActiveScene().buildIndex;
     IsLoading     = true;
     OnLoading?.Invoke(this, IsLoading);
 }
Beispiel #18
0
        /// <summary>
        /// 获取任务状态信息
        /// </summary>
        private Aria2cGlobalStat GetTaskStatus()
        {
            try
            {
                if (IsPauseAll || CountDownTask() == 0)
                {
                    return(null);
                }

                //复制key
                List <string> keyList = new List <string>();
                foreach (var key in downLoadDict.Keys)
                {
                    keyList.Add(key);
                }

                int iDownloadingCount = 0, iTaskCount = 0;
                //int iMaxCount = maxConcurrentDowns.Value; //不再限定最大轮询数量,可能造成任务状态更新丢失
                //if (iMaxCount <= 5) { iMaxCount *= 5; }
                //else if (iMaxCount <= 20) { iMaxCount *= 3; }
                //else if (iMaxCount <= 40) { iMaxCount *= 2; }
                //else { iMaxCount += 16; }
                Aria2cGlobalStat status = null;
                //遍历查询状态
                for (int i = 0; i < keyList.Count; i++)
                {
                    iTaskCount++;
                    try
                    {
                        Aria2cTask task = TellStatus(keyList[i]);
                        if (task == null)//当一个任务出问题,则本次循环就放弃掉.例如被杀掉进程后,要是还循环获取状态,是始终拿不到状态的.
                        {
                            break;
                        }

                        /*优化逻辑,注释掉
                         * if (task.Status == Aria2cTaskStatus.Paused)
                         *  //当一个任务出现暂停,说明全部任务都是暂停状态,停止轮询(×  web ui可以单任务暂停)
                         *  break;
                         */

                        if (task.Status == Aria2cTaskStatus.Active)
                        {
                            OnLoading?.Invoke(this, new Aria2cTaskEvent(task));
                            iDownloadingCount++;
                            if (iDownloadingCount == maxConcurrentDowns.Value)//下载数统计达到最大下载数,后续任务都是waiting,已完成的已遍历过,跳过等待任务
                            {
                                status = this.GetGlobalStat();
                                if (status != null)
                                {
                                    i += (int)status.NumWaiting;
                                }
                            }
                        }
                        else if (task.Status == Aria2cTaskStatus.Waiting)
                        {
                            continue;
                        }

                        if (downLoadDict[task.Gid].Status != task.Status)
                        {
                            OnStatusChanged(task);
                        }

                        if (stoppedStatus.Contains(task.Status))
                        {
                            if (downLoadDict.ContainsKey(task.Gid))
                            {
                                RemoveDownTask(task.Gid);
                            }
                        }
                        else
                        {
                            UpdateDownTask(task);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }

                    //if (iTaskCount >= iMaxCount) //不再限定最大轮询数量,可能造成任务状态更新丢失
                    //    break;
                }

                return(status);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            }
        }