Exemplo n.º 1
0
 void OnReset(ResetEvent e)
 {
     for (int i = 0; i < _times.Count; i++)
     {
         _times[i] = 0;
     }
 }
Exemplo n.º 2
0
        public MidiEvent Read(MidiReader reader, ReadingSettings settings, byte currentStatusByte)
        {
            SystemRealTimeEvent systemRealTimeEvent = null;

            switch (currentStatusByte)
            {
            case EventStatusBytes.SystemRealTime.ActiveSensing:
                systemRealTimeEvent = new ActiveSensingEvent();
                break;

            case EventStatusBytes.SystemRealTime.Continue:
                systemRealTimeEvent = new ContinueEvent();
                break;

            case EventStatusBytes.SystemRealTime.Reset:
                systemRealTimeEvent = new ResetEvent();
                break;

            case EventStatusBytes.SystemRealTime.Start:
                systemRealTimeEvent = new StartEvent();
                break;

            case EventStatusBytes.SystemRealTime.Stop:
                systemRealTimeEvent = new StopEvent();
                break;

            case EventStatusBytes.SystemRealTime.TimingClock:
                systemRealTimeEvent = new TimingClockEvent();
                break;
            }

            systemRealTimeEvent.Read(reader, settings, MidiEvent.UnknownContentSize);
            return(systemRealTimeEvent);
        }
Exemplo n.º 3
0
        public static void Main(String[] args)
        {
            // Configure a logger to capture the output of the library
            Tracer.Trace = new ConsoleLogger();

            try
            {
                using (var subscriber = new Subscriber())
                {
                    SendMessages();

                    Console.WriteLine($" [{Thread.CurrentThread.ManagedThreadId}] Start receiving messages.");

                    subscriber.Start();

                    Console.WriteLine(ResetEvent.Wait(1.ToMinutes()) ? "All messages received" : "Timeout :(");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex}");
            }

            Console.WriteLine("Press <enter> to exit.");
            Console.ReadLine();
        }
Exemplo n.º 4
0
        /// <summary> Method executed in parallel </summary>
        /// <param name="exceptionHandler"> Method which will be called in case of any thread raise an exception </param>
        public void Execute(Action <Exception> exceptionHandler)
        {
            Guard.NotNull(exceptionHandler, $"{nameof(exceptionHandler)}");

            try
            {
                while (_taskQueue.NotEmpty())
                {
                    _taskQueue.TryDequeue(out var task);
                    if (task == null)
                    {
                        return;
                    }
                    _taskProcessLogic.ProcessTask(task);
                    TaskSequenceNumber++;
                    ResetEvent.Set();
                }
            }
            catch (ThreadInterruptedException ex)
            {
                Log.Information($"Exception thrown {ex}");
            }
            catch (Exception ex)
            {
                Log.Information($"Exception thrown {ex}");
                exceptionHandler?.Invoke(ex);
            }
        }
Exemplo n.º 5
0
        public override void HandleMessage(INetPacket packet)
        {
            Debug.WriteLine($"Message received: \"{packet.GetType().Name}\" ({BattleId})");
            if (Socket == null || ResetEvent.SafeWaitHandle.IsClosed)
            {
                return;
            }
            ResetEvent.Set();

            if (BattleId < 2)
            {
                var ser = (BattleServer)Server;
                switch (packet)
                {
                case PBEActionsResponsePacket arp:
                {
                    ser.ActionsSubmitted(this, arp.Actions);
                    break;
                }

                case PBEPartyResponsePacket prp:
                {
                    Party = prp.Party;
                    ser.PartySubmitted(this);
                    break;
                }

                case PBESwitchInResponsePacket sirp:
                {
                    ser.SwitchesSubmitted(this, sirp.Switches);
                    break;
                }
                }
            }
        }
Exemplo n.º 6
0
        private void Restart()
        {
            Debug.Log("RESTART!");
            audioManager.RestartLastCheckpoint();

            ResetEvent?.Invoke();
        }
Exemplo n.º 7
0
 /// <inheritdoc/>
 public virtual void Reset()
 {
     m_PixelGrid.Clear();
     m_Detector?.Reset();
     m_Encoder?.Reset();
     ResetEvent?.Invoke();
 }
Exemplo n.º 8
0
 public void ResetTrigger()
 {
     if (ResetEvent != null)
     {
         ResetEvent.Invoke();
     }
 }
Exemplo n.º 9
0
        private void StreamOutput()
        {
            string output = JsonConvert.SerializeObject(_account.Loans);

            Console.WriteLine(output);

            ResetEvent.Set();
        }
Exemplo n.º 10
0
 private void Start()
 {
     gameOver = false;
     DontDestroyOnLoad(gameObject);
     restartButton.gameObject.SetActive(false);
     resetEvent = new ResetEvent();
     bgm        = true;
 }
Exemplo n.º 11
0
 public void SendMask(string strMask)
 {
     if (CurState == OptStatus.RUNNING_HAVEMASK)
     {
         ShowData.GetInstance().MaskCode = strMask;
         ResetEvent.Set();
     }
 }
Exemplo n.º 12
0
    public static ResetEvent Create(GameObject gameObject)
    {
        ResetEvent e = new ResetEvent();

        e.Type = QuarkEventType.Reset;
        e.Id   = gameObject.GetInstanceID();
        e.Tag  = gameObject.tag;
        return(e);
    }
Exemplo n.º 13
0
 public void Restart()
 {
     Button.SetParent(transform);
     Button.localPosition = new Vector3(-200, 290, -1);
     startButton.setClick(true);
     // TODO: Event restart to grid
     CreateVarDict();
     ResetEvent?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 14
0
        private void StreamOutput()
        {
            foreach (var account in _accounts)
            {
                string output = JsonConvert.SerializeObject(account);
                Console.WriteLine(output);
            }

            ResetEvent.Set();
        }
Exemplo n.º 15
0
        private void ResetAgent()
        {
            vehicle.CollisionCount = 0;
            updateTime             = Time.time;
            stats = default;
            resetter.Reset();
            road.OnReset();

            ResetEvent?.Invoke(name);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;

            List <WorldPlayer> players = new List <WorldPlayer>();

            bool isWorldReset = message.GetBoolean(0);

            uint index = 1;

            while (index + 2 < message.Count)
            {
                WorldPlayer player = worldCon.Players.GetPlayer(message.GetInt(index));
                if (player != null)
                {
                    if (!handled)
                    {
                        Vector loc = new Vector(message.GetInt(index + 1), message.GetInt(index + 2));
                        player.SetLocationInternal(loc);

                        if (!isWorldReset)
                        {
                            player.Respawn();
                        }
                    }

                    players.Add(player);
                }

                index += 3;
            }

            if (isWorldReset)
            {
                ResetEvent resetEvent = new ResetEvent()
                {
                    Raw = message
                };

                connectionBase.RaiseServerEvent <ResetEvent>(resetEvent);
            }
            else
            {
                for (int i = 0; i < players.Count; i++)
                {
                    KillEvent killEvent = new KillEvent()
                    {
                        Raw    = message,
                        Player = players[i]
                    };

                    connectionBase.RaiseServerEvent <KillEvent>(killEvent);
                }
            }
        }
Exemplo n.º 17
0
        public bool WaitForResponse()
        {
            bool receivedResponseInTime = ResetEvent.WaitOne(1000 * 5);

            if (!receivedResponseInTime)
            {
                Console.WriteLine($"Kicking client ({BattleId} {PlayerName})");
                Server.DisconnectClient(Id);
            }
            return(receivedResponseInTime);
        }
Exemplo n.º 18
0
#pragma warning disable 1998
            public async Task HandleAsync(TestEvent args)
#pragma warning restore 1998
            {
                Thread.Sleep(50);
                HandleGotCalled = true;

                if (ResetEvent != null)
                {
                    ResetEvent.Set();
                }
            }
Exemplo n.º 19
0
 void OnReset(ResetEvent e)
 {
     foreach (var chunk in _chunks)
     {
         Destroy(chunk.gameObject);
     }
     _chunks.Clear();
     _initialized           = false;
     _chunkDifficultyOffset = 0;
     _currentChunkCount     = 0;
 }
Exemplo n.º 20
0
#pragma warning disable 1998
            public async Task HandleAsync(TestEvent args)
#pragma warning restore 1998
            {
                Console.WriteLine("Sleeping...");
                Thread.Sleep(50);
                Console.WriteLine("Awake again...");
                HandleGotCalled = true;
                Console.WriteLine("HandleGotCalled = true");

                ResetEvent?.Set();
                Console.WriteLine("Event set...");
            }
Exemplo n.º 21
0
        public void DoWorkTest_WaitUntilCompleted()
        {
            // Arrange
            WorkType  = WorkType.GenerateReports;
            WorkHours = 8;

            // Act
            Task.Run(() => Worker.StartWork(WorkType, WorkHours));

            // Block Current Thread
            ResetEvent.Wait();
        }
        public override void Initialize()
        {
            base.Initialize();

            Watcher          = new PhysicalFileSystemWatcher(FileSystem, FileSystemPath.Root);
            Watcher.Changed += (sender, e) =>
            {
                Count++;
                ResetEvent.Set();
            };
            Watcher.EnableRaisingEvents = true;
        }
        public void NotifyOtherThreads()
        {
            lock (_testLock)
            {
                if (IsCheckComplete)
                {
                    return;
                }

                IsCheckComplete = true;
                ResetEvent.Set();
            }
        }
Exemplo n.º 24
0
        private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs args)
        {
            var e = args.ExceptionObject as Exception;

            Log.WriteError("Unhandled Exception", "{0}\n{1}", e?.Message, e?.StackTrace);

            if (args.IsTerminating)
            {
                AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;

                ResetEvent.Set();
            }
        }
        public void NotifyOtherThreads()
        {
            lock (_testLock)
            {
                if (IsCheckComplete)
                {
                    return;
                }

                CapturedTestMessage = ViewModel.Messages.FirstOrDefault(a => a.Text == TestMessage);

                IsCheckComplete = true;
                ResetEvent.Set();
            }
        }
Exemplo n.º 26
0
        public void Update(double time)
        {
            if (!IsRun)
            {
                return;
            }

            if (_updInterval + _lastUpdate < time)
            {
                _lastUpdate = time;

                ResetEvent?.Invoke(this, null);
                _rootSelector.Execute(time);
            }
        }
Exemplo n.º 27
0
        void autoReset()
        {
            var rst = new ResetEvent();

            var retries = retry(rst, 10);

            ThreadPool.QueueUserWorkItem((r) =>
            {
                Thread.Sleep(251);
                r.Set(true);
            }, rst, true);

            retries.Wait();
            $"autoReset retries: {retries.Result.r} [Expect > 0]".AsInfo();
        }
Exemplo n.º 28
0
        void noReset()
        {
            var rst = new ResetEvent(false);

            var retries = retry(rst, 300);

            ThreadPool.QueueUserWorkItem((r) =>
            {
                Thread.Sleep(10);
                r.Set(true, false);
            }, rst, true);

            retries.Wait();
            $"noReset retries: {retries.Result.r} [Expect 0]".AsInfo();
        }
        public void NotifyOtherThreads()
        {
            lock (_testLock)
            {
                if (IsCheckComplete)
                {
                    return;
                }

                Map.InitiatorLatitude  = "498";
                Map.InitiatorLongitude = "498";
                IsCheckComplete        = true;
                ResetEvent.Set();
            }
        }
Exemplo n.º 30
0
        public int MakeEventsEachRaid(RaidInfo info, string start, string end)
        {
            DateTime          startDate = DateTime.Parse(start);
            DateTime          endDate   = DateTime.Parse(end);
            List <ResetEvent> events    = new List <ResetEvent>();
            DateTime          termDate  = DateTime.Parse(info.start);

            while (startDate < endDate)
            {
                if (true == info.isThurReset)
                {
                    if ((DayOfWeek.Thursday == startDate.DayOfWeek) &&
                        (startDate >= termDate))
                    {
                        var newEvent = new ResetEvent(info.name, startDate, info.resourceId);
                        events.Add(newEvent);
                        startDate = startDate.AddDays(7f);
                    }
                    else
                    {
                        startDate = startDate.AddDays(1f);
                    }
                }
                else
                {
                    while (startDate > termDate)
                    {
                        termDate = termDate.AddDays(info.term);
                    }

                    if (startDate == termDate)
                    {
                        var newEvent = new ResetEvent(info.name, startDate, info.resourceId);
                        events.Add(newEvent);
                        startDate = startDate.AddDays(info.term);
                        termDate  = termDate.AddDays(info.term);
                    }
                    else
                    {
                        startDate = startDate.AddDays(1f);
                    }
                }
            }

            int insertCount = ResetEventRepo.Get().Add(events);

            return(insertCount);
        }