Exemplo n.º 1
0
        IEnumerator CallWrapper()
        {
            yield return(null);

            IEnumerator e = coroutine;

            while (running)
            {
                if (paused)
                {
                    yield return(null);
                }
                else
                {
                    if (e != null && e.MoveNext())
                    {
                        yield return(e.Current);
                    }
                    else
                    {
                        running = false;
                    }
                }
            }

            FinishedHandler handler = Finished;

            if (handler != null)
            {
                handler(stopped);
            }
        }
Exemplo n.º 2
0
 // Constructor.
 public Timer(float seconds, FinishedHandler finishedCallback = null,
              bool running = true, bool loop = true)
 {
     this.secondsTarget    = seconds;
     this.finishedCallback = finishedCallback;
     this.running          = running;
     this.loop             = loop;
 }
Exemplo n.º 3
0
 public Task(
     IEnumerator c,
     FinishedHandler handler,
     bool autoStart = true)
     : this(c, autoStart)
 {
     Finished += handler;
 }
Exemplo n.º 4
0
        private void _taskStateFinished(bool manual)
        {
            FinishedHandler handler = _finished;

            if (handler != null)
            {
                handler(manual);
            }
        }
Exemplo n.º 5
0
        void TaskFinished(bool manual)
        {
            FinishedHandler handler = Finished;

            if (handler != null)
            {
                handler(manual);
            }
        }
Exemplo n.º 6
0
 public bool AddFinishedListener(FinishedHandler handler)
 {
     if (this.m_finishedListeners.Contains(handler))
     {
         return false;
     }
     this.m_finishedListeners.Add(handler);
     return true;
 }
Exemplo n.º 7
0
 private void InitControls()
 {
     txtMsg.Text          = string.Empty;
     progressBar1.Visible = false;
     _progressHandler     = new ProgressHandler(DoProgress);
     _writeLogHandler     = new WriteLogHandler(DoLog);
     _finishedHandler     = new FinishedHandler(Finished);
     FormClosing         += new FormClosingEventHandler(frmActionExecutor_FormClosing);
 }
Exemplo n.º 8
0
        public void TimerFinished(bool manual)
        {
            FinishedHandler handler = Finished;

            if (handler != null)
            {
                handler(manual);
            }
        }
Exemplo n.º 9
0
 public BinaryExecuter(string binaryPath, string args, string transactionId, string invocationId, FinishedHandler finishedHandler)
 {
     _binaryPath       = binaryPath;
     _workingDirectory = Path.GetDirectoryName(_binaryPath);
     _args             = args;
     _transactionid    = transactionId;
     _invocationId     = invocationId;
     _finishedHandler  = finishedHandler;
 }
Exemplo n.º 10
0
    void TaskFinished(bool manual, string name)
    {
        FinishedHandler handler = Finished;

        if (handler != null)
        {
            handler(manual, name);
        }
    }
Exemplo n.º 11
0
        private void TaskFinished(bool manual)
        {
            FinishedHandler finished = this.Finished;

            if (finished != null)
            {
                finished(manual);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 结束
        /// </summary>
        public void finishExec()
        {
            // 目标协程执行结束
            FinishedHandler handler = EventFinished;

            if (handler != null)
            {
                handler(_bStoped, this);
            }
        }
Exemplo n.º 13
0
        void TaskFinished(bool manual)
        {
            FinishedHandler handler = Finished;

            if (handler != null)
            {
                handler(manual);
            }
            EventDelegate.Execute(onFinish);
        }
Exemplo n.º 14
0
    void TaskFinished(bool manual)
    {
        FinishedHandler handler = Finished;

        if (handler != null)
        {
            handler(manual);
        }
        if (flushAtFinish)
        {
            Flush();
        }
    }
Exemplo n.º 15
0
 // Constructor.
 public Timer(float seconds, FinishedHandler FinishedCallback = null, bool loop = true,
     bool clearOnRun = false, StartedHandler StartedCallback = null,
     StoppedHandler StoppedCallback = null, TickedHandler TickedCallback = null)
 {
     this.secondsTarget = seconds;
     this.Finished = FinishedCallback;
     this.loop = loop;
     this.clearOnRun = clearOnRun;
     this.Started = StartedCallback;
     this.Stopped = StoppedCallback;
     this.Ticked = TickedCallback;
     runner = new Runner(OnStarted, OnStopped);
 }
Exemplo n.º 16
0
		/// <summary>
		/// Erzeugt eine neue Datenkanalinstanz.
		/// </summary>
		/// <param name="socket">Der zugehörige Datenkanal.</param>
		/// <param name="onFinished">Methode, die nach dem Schliessen des Datenkanals aufgerufen werden soll.</param>
		public DataChannel(Socket socket, FinishedHandler onFinished)
		{
			// Remember
			m_OnFinished = onFinished;

			// Attach to socket
			m_Socket = socket;

			// Use asynchronous
			m_Socket.Blocking = false;

            // Report
            FTPMain.Log("DataChannel created");
		}
Exemplo n.º 17
0
        /// <summary>
        /// Erzeugt eine neue Datenkanalinstanz.
        /// </summary>
        /// <param name="socket">Der zugehörige Datenkanal.</param>
        /// <param name="onFinished">Methode, die nach dem Schliessen des Datenkanals aufgerufen werden soll.</param>
        public DataChannel(Socket socket, FinishedHandler onFinished)
        {
            // Remember
            m_OnFinished = onFinished;

            // Attach to socket
            m_Socket = socket;

            // Use asynchronous
            m_Socket.Blocking = false;

            // Report
            FTPMain.Log("DataChannel created");
        }
Exemplo n.º 18
0
            public void UpdateTime(float time)
            {
                time = ignoreTimeScale ? time - currentTime : time;

                if (running)
                {
                    if (paused)
                    {
                        return;
                    }

                    switch (timeUnit)
                    {
                    case TimeUnit.FrameRate:
                        currentTime += 1;
                        break;

                    case TimeUnit.Second:
                        currentTime += time;
                        break;

                    case TimeUnit.CentiSecond:
                        currentTime += time * 100;
                        break;

                    case TimeUnit.MilliSecond:
                        currentTime += time * 1000;
                        break;
                    }

                    if (currentTime >= attackTime)
                    {
                        if (HasRepeat)
                        {
                            ResetState();
                        }
                        else
                        {
                            Stop();
                        }

                        FinishedHandler handle = Finished;
                        if (handle != null)
                        {
                            handle(stopped);
                        }
                    }
                }
            }
Exemplo n.º 19
0
 // Constructor.
 public Timer(float seconds, FinishedHandler FinishedCallback = null, bool loop   = true,
              bool clearOnRun = false, StartedHandler StartedCallback             = null,
              StoppedHandler StoppedCallback = null, TickedHandler TickedCallback = null)
 {
     if (seconds <= 0.0f)
     {
         Debug.LogError("Prevented instantiation of a timer that loops every " + seconds
                        + " seconds. Make sure timers run for longer than 0 seconds. " +
                        "The timer has been set to loop every second to prevent an infinite loop.");
         seconds = 1.0f;
     }
     this.secondsTarget = seconds;
     this.Finished      = FinishedCallback;
     this.loop          = loop;
     this.clearOnRun    = clearOnRun;
     this.Started       = StartedCallback;
     this.Stopped       = StoppedCallback;
     this.Ticked        = TickedCallback;
     runner             = new Runner(OnStarted, OnStopped);
 }
        /// <summary>
        /// 每个资源加载完成回调函数
        /// </summary>
        private void CallbackOneLoadFinished(bool manual)
        {
            m_CurFreeCoroutineNum++;
            m_completeIndex++;
            FinishedHandler handler = OneFinished;

            if (handler != null)
            {
                handler(manual);
            }

            if (isDone())
            {
                CallbackListLoadFinished(manual);
            }
            else
            {
                LoadNext();
            }
        }
Exemplo n.º 21
0
            private IEnumerator CallWrapper()
            {
                //Debug.Log("CallWrapper");
                yield return(null);

                UnityEngine.Profiling.Profiler.BeginSample("CallWrapper 1: " + _coroutine.ToString());
                IEnumerator e = _coroutine;

                UnityEngine.Profiling.Profiler.EndSample();
                while (running)
                {
                    if (paused)
                    {
                        yield return(null);
                    }
                    else
                    {
                        UnityEngine.Profiling.Profiler.BeginSample("CallWrapper 2: " + e);
                        bool flag = e.MoveNext();
                        UnityEngine.Profiling.Profiler.EndSample();

                        if (e != null && flag)
                        {
                            yield return(e.Current);
                        }
                        else
                        {
                            running = false;
                        }
                    }
                }
                UnityEngine.Profiling.Profiler.BeginSample("CallWrapper 3: " + e.ToString());
                FinishedHandler handler = Finished;

                if (handler != null)
                {
                    handler(stopped);
                }
                UnityEngine.Profiling.Profiler.EndSample();
            }
Exemplo n.º 22
0
 public TaskRunner(IEnumerator c, FinishedHandler handler, bool autoStart = true) : this(c, autoStart)
 {
     TaskFinishedHandler += handler;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Start sending <paramref name="recordedActions"/> to the <see cref="window"/> and invoke <paramref name="finishedCallback"/> when done.
        /// </summary>
        public static void StartPlayback(EditorWindow window, IList <UserAction> recordedActions, FinishedHandler finishedCallback)
        {
            foreach (EditorWindowTestPlayer testPlayer in Resources.FindObjectsOfTypeAll <EditorWindowTestPlayer>())
            {
                testPlayer.Close();
            }

            IsPlaying = true;

            EditorWindowTestPlayer player = CreateInstance <EditorWindowTestPlayer>();

            player.ShowUtility();
            player.Finished += finishedCallback;
            player.window    = window;

            foreach (UserAction action in recordedActions)
            {
                TestableEditorElements.StartPlayback(action.PrepickedSelections);
                player.window.SendEvent(action.Event);
                player.SendEvent(EditorGUIUtility.CommandEvent("Wait"));
            }

            player.SendEvent(EditorGUIUtility.CommandEvent("Finished"));
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            var player = new MoviePlayer();

            player.CurrentMovie = "Star Wars";

            //player.Finished += DisplayFinishedMessage;
            //player.Finished += (
            //    (name) =>
            //    {
            //        int a = 3;
            //        a += 1;
            //        Console.WriteLine($"finished movie {name}.");
            //    }
            //);

            FinishedHandler handler = ((name) => Console.WriteLine($"finished movie {name}."));

            player.Finished += handler;

            player.Finished += (name) => Console.WriteLine("second handler too!");

            player.Finished -= handler;

            // handler would no longer be called

            player.Finished += handler;

            player.PlayMovie();

            // ////////////////////// LAMBDA EXPRESSIONS WITH LINQ

            var movieNames = new List <string>()
            {
                "Star Wars",
                "Toy Story",
                "Jurassic Park",
                "The Godfather",
                "The Avengers",
                "Cinderella"
            };

            //int maxLength = 0;
            //for (int i = 0; i < movieNames.Count; i++)
            //{
            //    if (movieNames[i].Length > maxLength)
            //    {

            //    }
            //}

            movieNames.Max(movieName => movieName.Length); // returns 13

            // first movie name that starts with a T
            movieNames.First(x => x[0] == 'T');

            // LINQ Language-Integrated Query Language
            // works on any IEnumerable<> or IQueryable<>

            var y = movieNames.Select(x => x[1]).ToList(); // get the second character of each movie name
        }
Exemplo n.º 25
0
 // Change the timer's finished callback function.
 public void SubscribeToFinished(FinishedHandler Callback)
 {
     Finished = Callback;
 }
Exemplo n.º 26
0
        void Finished(bool manual)
        {
            FinishedHandler handler = TaskFinishedHandler;

            handler?.Invoke(manual);
        }
Exemplo n.º 27
0
		/// <summary>
		/// Erzeugt eine neue Client Verbindung.
		/// </summary>
		/// <param name="socket">Netzwerkverbindung zum Client.</param>
		/// <param name="file">Die Datei, die diesem Client zugeordnet ist.</param>
		/// <param name="onFinished">Methode zum Rückrufe nach Beenden der Verbindung.</param>
		public FTPClient(Socket socket, FileInfo file, FinishedHandler onFinished)
		{
			// Remember
			m_OnFinished = onFinished;
			m_Socket = socket;
			m_File = file;

			// Asnychronous
			m_Socket.Blocking = false;

			// Start reply
			Send(220, "FTP Wrap");

			// Register
			m_Processors["ABOR"] = ProcessABOR;
			m_Processors["RETR"] = ProcessRETR;
			m_Processors["LIST"] = ProcessLIST;
			m_Processors["PASV"] = ProcessPASV;
			m_Processors["TYPE"] = ProcessTYPE;
			m_Processors["QUIT"] = ProcessQUIT;
			m_Processors["USER"] = ProcessUSER;
			m_Processors["PASS"] = ProcessPASS;
			m_Processors["SYST"] = ProcessSYST;
			m_Processors["CWD"] = ProcessCWD;
		}