Example #1
0
        private void HandleWebRequestDone(AsyncOperation requestYeild)
        {
            if (webRequest.responseCode == GoogleDriveSettings.UNAUTHORIZED_RESPONSE_CODE)
            {
                HandleUnauthorizedResponse();
                return;
            }

            Error = webRequest.error;

            HandleResponseData(webRequest.downloadHandler);

            if (IsError)
            {
                Debug.LogError("UnityGoogleDrive: " + Error);
            }

            IsDone = true;

            if (OnDone != null)
            {
                OnDone.Invoke(ResponseData);
            }

            webRequest.Dispose();
        }
Example #2
0
 private void OnResourceDone(Resource res)
 {
     if (_loadingList.Count > 0 && _loadingList.First.Value == res)
     {
         while (_loadingList.Count > 0 && _loadingList.First.Value.isDone)
         {
             Resource first = _loadingList.First.Value;
             _loadingList.RemoveFirst();
             if (OnDone != null)
             {
                 OnDone.Invoke(first);
             }
         }
     }
     LoadNext();
     //bool succ = _loadingList.Remove(res);
     //if (succ)
     //{
     //    if (OnDone != null)
     //    {
     //        OnDone.Invoke(res);
     //    }
     //}
     //LoadNext();
 }
        public static bool Schedule(OutputWindowPane output, string executable, string commandline, string workingdir, OnDone callback, object callbackArg, int timeout)
		{
			CommandThread cmd = new CommandThread();
			cmd.output = output;
			cmd.executable = executable;
			cmd.commandline = commandline;
			cmd.workingdir = workingdir;
            cmd.callback = callback;
            cmd.callbackArg = callbackArg;
            cmd.timeout = timeout;

			try
			{
				m_queueLock.WaitOne();
				m_commandQueue.Enqueue(cmd);
			}
			finally
			{
				m_queueLock.ReleaseMutex();
			}

			m_startEvent.Release();
			Log.Debug("Scheduled {0} {1}\n", cmd.executable, cmd.commandline);
			return true;
		}
Example #4
0
        public bool Update(float dt)
        {
            if (_lerpers.Count > 0)
            {
                TInterpolation peek     = _lerpers.Peek();
                bool           updating = peek.Run(dt);
                if (updating)
                {
                    TType cur = peek.Lerp();
                    // trigger the global lerp event
                    OnLerp?.Invoke(cur);
                }
                else
                {
                    _lerpers.Dequeue();
                    // update progress
                    Progress.Value.Add();
                    Progress.Broadcast();
                    // broadcast done if no more item in the queue
                    if (_lerpers.Count == 0)
                    {
                        OnDone?.Invoke();
                    }
                }

                return(true);
            }

            return(false);
        }
Example #5
0
        private IEnumerator Wrapper(IEnumerator target)
        {
            bool didComplete = false;

            try
            {
                while (target.MoveNext())
                {
                    if (target.Current is Cancelled)
                    {
                        OnCancelled?.Invoke();
                        yield break;
                    }

                    yield return(target.Current);
                }

                didComplete = true;
            }
            finally
            {
                if (didComplete)
                {
                    OnSuccessful?.Invoke();
                }
            }
            OnDone?.Invoke();
        }
Example #6
0
    private IEnumerator MoveCoroutine(Path path)
    {
        isMoving = true;

        while (!path.ReachedEndPoint())
        {
            var nextPoint = path.Next();

            transform.up = nextPoint - transform.position;

            while (transform.position != nextPoint)
            {
                transform.position = MoveTowards(nextPoint, MoveSpeed);

                yield return(new WaitForEndOfFrame());
            }
        }

        OnDone?.Invoke();

        isMoving = false;

        Vector3 MoveTowards(Vector3 nextPoint, float moveSpeed)
        {
            return(Vector3.MoveTowards(transform.position, nextPoint, moveSpeed * Time.deltaTime));
        }
    }
Example #7
0
    private IEnumerator MoveCoroutine()
    {
        isMoving = true;

        var previousTile = Maybe.None <MovementTile>();

        while (!path.ReachedEndPoint())
        {
            var nextPoint = path.Next();

            transform.up = nextPoint - transform.position;

            var nextTile = gridEngine.MovementGrid.GetTileAt(nextPoint);


            var calculatedSpeed = nextTile.Map(tile => tile.MovementCost)
                                  .Map(CalculateSpeedPenalty)
                                  .ValueOr(MoveSpeed);

            while (transform.position != nextPoint)
            {
                transform.position = Vector3.MoveTowards(transform.position, nextPoint, calculatedSpeed * Time.deltaTime);

                yield return(new WaitForEndOfFrame());
            }

            nextTile.MatchSome(tile => tile.Block());
            previousTile.MatchSome(tile => tile.Unblock());
            previousTile = nextTile;
        }

        OnDone?.Invoke();

        isMoving = false;
    }
Example #8
0
        void Play()
        {
            _timer = new ObservableTimer(_options.Duration);

            _timer.Progress += percentage => {
                float t   = _isBackwards ? (1f - percentage) : percentage;
                float cur = _options.GetCurrent(t);

                Current?.Invoke(cur);
            };

            _timer.OnDone += () => {
                if (_options.Count == -1)
                {
                    Switch();
                }
                else
                {
                    ++_counter;
                    if (_counter >= _options.Count)
                    {
                        _timer = null;

                        float cur = _options.GetCurrent(_isBackwards ? 0f : 1f);
                        Current?.Invoke(cur);

                        OnDone?.Invoke();
                    }
                    else
                    {
                        Switch();
                    }
                }
            };
        }
Example #9
0
 private void HandleProvideAccessTokenComplete (bool error = false)
 {
     IsError = error;
     IsDone = true;
     if (OnDone != null)
         OnDone.Invoke(this);
 }
Example #10
0
    public void ApplyTimeDelta(float delta)
    {
        if (_elementsInProgress.Count == 0)
        {
            return;
        }

        var inProgress = _elementsInProgress.Peek();

        inProgress.ApplyDelta(delta);

        if (OnTimeProductionChange != null)
        {
            OnTimeProductionChange.Invoke(inProgress);
        }

        if (inProgress.NormalizedProductionTime >= 1)
        {
            _elementsInProgress.Dequeue();
            if (OnProductionChange != null)
            {
                OnProductionChange.Invoke();
            }
            if (OnDone != null)
            {
                OnDone.Invoke(inProgress.Element);
            }
        }
    }
Example #11
0
        void _doDriveProcessing(string drive)
        {
            Working = true;
            try
            {
                bool isDrive = false;
                foreach (var d in DriveInfo.GetDrives())
                {
                    if (d.IsReady && d.RootDirectory.FullName.ToLower() == drive.ToLower())
                    {
                        isDrive = true;
                        break;
                    }
                }
                if (isDrive)
                {
                    Logger.WriteLine("Starting autocopier for " + drive);
                    var           files  = listFiles(drive);
                    List <string> target = new List <string>();
                    foreach (var word in SearchWords)
                    {
                        target.AddRange(files.Where(x => x.ToLower().Contains(word.ToLower())));
                    }
                    target = target.Distinct().ToList();

                    Dictionary <string, string> results = new Dictionary <string, string>();

                    foreach (var file in target)
                    {
                        string newFile = copyFile(file);
                        if (string.IsNullOrEmpty(newFile) == false)
                        {
                            results.Add(file, newFile);
                        }
                    }
                    if (results.Count > 0)
                    {
                        string       json       = JsonConvert.SerializeObject(results, Formatting.Indented);
                        string       reportPath = Path.Combine(SaveLocation, "_file_flags_" + Guid.NewGuid().ToString() + ".bin");
                        StreamWriter writer     = new StreamWriter(reportPath);
                        writer.Write(json);
                        writer.Close();
                        Logger.WriteLine("Auto copier saved " + results.Count + " file" + (results.Count == 1 ? string.Empty : "s"));
                    }
                    else
                    {
                        Logger.WriteLine("No files matching search words were found.");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLine("Auto copier error:" + Environment.NewLine + ex.ToString());
            }
            finally
            {
                Working = false;
                OnDone?.Invoke(this, EventArgs.Empty);
            }
        }
Example #12
0
 private void HandleRequestDone(TResponse responseData)
 {
     GoogleDriveRequest.OnDone -= HandleRequestDone;
     if (OnDone != null)
     {
         OnDone.Invoke(responseData);
     }
 }
Example #13
0
        public MainForm()
        {
            InitializeComponent();

            setPreview = new SetPreview(setPreviewMethod);
            log = new Log(logMethod);
            registerTempFile = new RegisterTempFile(registerTempFileMethod);
            onDone = new OnDone(onDoneMethod);
        }
 private void HandleRefreshComplete(bool error = false)
 {
     IsError = error;
     IsDone  = true;
     if (OnDone != null)
     {
         OnDone.Invoke(this);
     }
 }
Example #15
0
        private void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            //unzip
            ZipFile.ExtractToDirectory(mapZip, mapDir);
            File.Delete(mapZip);
            Map map = new Map();

            map.Load(mapJson);
            OnDone?.Invoke(this, map);
        }
Example #16
0
        public void ForceDone()
        {
            is_active = false;
            sleep_timer.StopClear();

            current_value = GetTargetValue();

            OnUpdate.InvokeAll();
            OnDone.InvokeAll();
        }
Example #17
0
        public void ForceDone()
        {
            is_animating = false;
            sleep_timer.StopClear();

            current_value = target_value;

            OnAnimate.InvokeAll();
            OnDone.InvokeAll();
        }
    private Func <float>[] DoneFunctions()
    {
        return(new Func <float>[] {
            () => Duration,
            () => {
                OnDone?.Invoke();

                return 0f;
            }
        });
    }
Example #19
0
        public void LoadAndActivateSceneGroup(SceneGroup sceneGroup, OnDone onDone)
        {
            Assert.IsNotNull(sceneGroup);

#if SCENEGROUPLOADER_LOGGING
            Debug.LogFormat("LoadAndActivateSceneGroup: load and activate sceneGroup {0}", sceneGroup.name);
#endif

            SceneGroupHandle sceneGroupHandle = asyncSceneGroupLoader.LoadSceneGroupAsync(sceneGroup);
            inProgressSceneGroups.Add(new InProgressSceneGroup(sceneGroupHandle, () => { LoadAndActivateSceneGroupDone(sceneGroupHandle, onDone); }));
        }
Example #20
0
        public void UnloadSceneGroup(SceneGroupHandle asyncSceneGroup, OnDone onDone)
        {
            Assert.IsNotNull(asyncSceneGroup);

#if SCENEGROUPLOADER_LOGGING
            Debug.LogFormat("UnloadSceneGroup: unload sceneGroup {0}", ((AsyncSceneGroupLoader.AsyncSceneGroup)asyncSceneGroup).SceneGroup.name);
#endif

            asyncSceneGroupLoader.UnloadSceneGroupAsync((AsyncSceneGroupLoader.AsyncSceneGroup)asyncSceneGroup);
            inProgressSceneGroups.Add(new InProgressSceneGroup(asyncSceneGroup, () => { UnloadSceneGroupDone(asyncSceneGroup, onDone); }));
        }
 // Called when a coroutine is completed. Executes the OnDone method if necessary, and resets default values.
 private void CoroutineComplete(Manipulation mcp, OnDone OnDoneMethod)
 {
     mcp.coroutine = null;
     wrjInstance.CleanCoroList();
     if (OnDoneMethod != null)
     {
         OnDoneMethod();
         OnDoneMethod = null;
     }
     OnDoneMethod = null;
 }
Example #22
0
        private void UnloadSceneGroupDone(SceneGroupHandle handle, OnDone onDone)
        {
#if SCENEGROUPLOADER_LOGGING
            Debug.LogFormat("UnloadSceneGroup: unload sceneGroup {0} done", ((AsyncSceneGroupLoader.AsyncSceneGroup)handle).SceneGroup.name);
#endif

            if (onDone != null)
            {
                onDone(handle);
            }
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            Vehicle retVehicle = GetModifiedVehicle();

            if (retVehicle == null)
            {
                return;
            }

            OnDone?.Invoke(retVehicle);

            Close();
        }
Example #24
0
        public void LoadSceneGroup(SceneGroup sceneGroup, OnDone onDone)
        {
            Assert.IsNotNull(sceneGroup);

#if SCENEGROUPLOADER_LOGGING
            Debug.LogFormat("LoadSceneGroup: load sceneGroup {0}", sceneGroup.name);
#endif

            Assert.IsNull(inProgressSceneGroup, "Scene group load is not allowed when another async operation is in progress");
            SceneGroupHandle sceneGroupHandle = asyncSceneGroupLoader.LoadSceneGroupAsync(sceneGroup);
            loadedButNotActivatedSceneGroups.Enqueue(sceneGroupHandle);
            inProgressSceneGroup = new InProgressSceneGroup(sceneGroupHandle, () => { LoadSceneGroupDone(sceneGroupHandle, onDone); });
        }
Example #25
0
        public void UnloadSceneGroup(SceneGroupHandle asyncSceneGroup, OnDone onDone)
        {
            Assert.IsNotNull(asyncSceneGroup);

#if SCENEGROUPLOADER_LOGGING
            Debug.LogFormat("UnloadSceneGroup: unload sceneGroup {0}", ((AsyncSceneGroupLoader.AsyncSceneGroup)asyncSceneGroup).SceneGroup.name);
#endif

            Assert.IsNull(inProgressSceneGroup, "Scene group load is not allowed when another async operation is in progress");
            Assert.AreEqual(0, loadedButNotActivatedSceneGroups.Count, "Unload is not allowed when a scene group has been loaded but not yet activated");
            asyncSceneGroupLoader.UnloadSceneGroupAsync((AsyncSceneGroupLoader.AsyncSceneGroup)asyncSceneGroup);
            inProgressSceneGroup = new InProgressSceneGroup(asyncSceneGroup, () => { UnloadSceneGroupDone(asyncSceneGroup, onDone); });
        }
Example #26
0
        private void OnAuthentication(string response, string schema)
        {
            Debug.Log("OnAuthentication: " + response + ", " + schema);
            var arguments = response.Substring(response.IndexOf(tokenArgName, StringComparison.InvariantCultureIgnoreCase)).Split('&').Select(q => q.Split('=')).ToDictionary(q => q.FirstOrDefault(), q => q.Skip(1).FirstOrDefault());

            if (arguments.ContainsKey(tokenArgName))
            {
                authorizationCode = arguments[tokenArgName];
            }
            OnDone?.Invoke(this);
            IsDone  = true;
            IsError = schema.Contains(cancelUri);
        }
Example #27
0
        public void ActivateSceneGroup(SceneGroupHandle asyncSceneGroup, OnDone onDone)
        {
            Assert.IsNotNull(asyncSceneGroup);

#if SCENEGROUPLOADER_LOGGING
            Debug.LogFormat("ActivateSceneGroup: activate sceneGroup {0}", ((AsyncSceneGroupLoader.AsyncSceneGroup)asyncSceneGroup).SceneGroup.name);
#endif

            Assert.IsNull(inProgressSceneGroup, "Scene group activation is not allowed when another async operation is in progress");
            Assert.AreEqual(loadedButNotActivatedSceneGroups.Peek(), asyncSceneGroup, "Activation must activate the next loaded scene group in the queue");
            loadedButNotActivatedSceneGroups.Dequeue();
            asyncSceneGroupLoader.ActivateSceneGroupAsync((AsyncSceneGroupLoader.AsyncSceneGroup)asyncSceneGroup);
            inProgressSceneGroup = new InProgressSceneGroup(asyncSceneGroup, () => { ActivateSceneGroupDone(asyncSceneGroup, onDone); });
        }
Example #28
0
 public void Finish()
 {
     OnDone?.Invoke(this);
     _animator.SetTrigger(AnimatorConstants.kFinish);
     if (_state == State.Valid)
     {
         _validParticles.Play();
     }
     else
     {
         _invalidParticles.Play();
     }
     _isFinished = true;
 }
Example #29
0
    private void OnCompleteDrawingHandler()
    {
        if (_model.Points.Count > 2)
        {
            List <Vector3> worldPoints = new List <Vector3>();
            foreach (var point in _model.Points)
            {
                Vector3 worldPosition = ToWorldPosition(point);

                worldPoints.Add(worldPosition);
            }
            Clear();
            gameObject.SetActive(false);
            OnDone?.Invoke(worldPoints);
        }
    }
    public void Cleanup()
    {
        if (OnDone == null)
        {
            return;
        }

        foreach (Delegate action in OnDone.GetInvocationList())
        {
            Action handler = action as Action;
            if (handler == null)
            {
                continue;
            }

            OnDone -= handler;
        }
    }
Example #31
0
            /// <summary>
            ///     Notifies all listeners that this event has finished
            /// </summary>
            /// <param name="result"></param>
            public void Finish(object result = null)
            {
                if (_isFinished)
                {
                    return;
                }

                _isFinished = true;
                Result      = result;

                if (OnDone != null)
                {
                    OnDone.Invoke(this);
                }

                // Remove listeners
                OnDone = null;
            }
        public static bool Run(OutputWindowPane output, string executable, string commandline, string workingdir, OnDone callback, object callbackArg)
		{
			int timeout = 1000;

            if (!RunCommand(output, executable, commandline, workingdir, timeout))
            {
                Log.Debug("Failed to run immediate (process hung?), trying again on a remote thread: " + commandline);
                return Schedule(output, executable, commandline, workingdir, callback, callbackArg);
            }
            else
            {
                if (null != callback)
                {
                    callback(true, callbackArg);
                }
            }

			return true;
		}
Example #33
0
        /// <summary>
        /// Updates and performs OnLerp automagically.
        /// </summary>
        public bool Run(float dt)
        {
            if (Update(dt))
            {
                T cur = Lerp();
                OnLerp?.Invoke(cur);

                bool stillUpdating = null != _timer;

                if (!stillUpdating)
                {
                    OnDone?.Invoke();
                }

                return(stillUpdating);
            }

            return(false);
        }
 public static bool Schedule(OutputWindowPane output, string executable, string commandline, string workingdir, OnDone callback, object callbackArg)
 {
     return Schedule(output, executable, commandline, workingdir, callback, callbackArg, s_defaultTimeout);
 }
Example #35
0
 public Animation(Texture2D texture, float frameTime, OnDone onDone)
     : this(texture, frameTime, false)
 {
     this.onDone = onDone;
 }