Example #1
0
        public ResponseMessage AppendEntry(AppendEntriesMessage message)
        {
            CheckFreeze();

            bool shouldBecomeFollower = false;

            TimerHelper.PauseTimer(HeartBeatTimer);
            if ((message.Term < this.term) ||
                !(this.leaderLog.Match(message.PreviousLogIndex, message.PreviousLogTerm)))
            {
                TimerHelper.StartTimer(HeartBeatTimer);
                return(new ResponseMessage(this.term, false, message.SharedId));
            }
            else if (message.Term > this.term)
            {
                this.term            = message.Term;
                shouldBecomeFollower = true;
            }
            leaderLog.AppendNewEntries(message.Entry);

            leaderLog.UpdateCommitIndex(message.LeaderCommit);

            if (shouldBecomeFollower)
            {
                node.SetState(new Follower(node, this.term, this.leaderLog));
            }

            return(new ResponseMessage(this.term, true, message.SharedId));
        }
Example #2
0
        public async Task <JsonResult> SelectTrump(int roundId, int trump, string username, bool isLast)
        {
            var result = await _gameService.SelectTrump(roundId, trump, username);

            if (result.IsSucessfull)
            {
                var gameId = result.Values[0] as string;
                if (trump > 0)
                {
                    await _gameHubContext.Clients.Group("Game" + gameId).SendAsync("TrumpCalled", result.Values[1]);
                }
                else
                {
                    await _gameHubContext.Clients.Group("Game" + gameId).SendAsync("TurnPassed", result.Values[1]);
                }

                var timer = TimerHelper.GetTimerForGameId(Convert.ToInt32(gameId));
                if (timer != null)
                {
                    timer.Restart();
                }

                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { error = result.Errors[0], isLast }));
            }
        }
Example #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //set the default focus for the editor
            TimerHelper.CallbackOnDelay(new InvokeInUIThreadDelegate(sourceControl.Focus), 50);
        }
Example #4
0
        private void HeartBeatOrEntryUpdate(Object source, ElapsedEventArgs e)
        {
            CheckFreeze();

            //UPDATE ENTRIES IN NODES THAT NEED TO APPEND AN ENTRY
            //OR JUST SEND AN HEARTBEAT (empty entry parameter)
            try
            {
                Random r = new Random();
                TimerHelper.PauseTimer(HeartBeatTimer);
                View v = this.node.manager.RequestView();
                foreach (KeyValuePair <int, Pingable> entry in v.pingables)
                {
                    List <Entry> l = new List <Entry>();

                    int ind = leaderLog.FollowersCommitIndex[entry.Key];
                    l = this.leaderLog.log.LogList.GetRange(ind, this.leaderLog.log.LogList.Count - ind);

                    RemoteAsyncCallAppendEntry((Node)entry.Value,
                                               new AppendEntriesMessage(this.term, 0, 0, ind, l, entry.Key, node.url));
                }
                TimerHelper.StartTimer(HeartBeatTimer);
            }
            catch (Exception ex) { }
        }
Example #5
0
        public override IEnumerator LoadModuleAsync()
        {
            if (UseAssetBundle)
            {
                var www = new WWW(UGCoreConfig.GetAssetBundlePath("AssetsDependences.pkg"));
                yield return(www);

                var assetbundleRequest = www.assetBundle.LoadAssetAsync("Assets/Resources/AssetsDependences", typeof(Object));
                yield return(assetbundleRequest);

                var assetDependences = assetbundleRequest.asset as TextAsset;
                if (assetDependences != null)
                {
                    AssetBundleManager.InitializeAssetManager(assetDependences.bytes);
                }
                else
                {
                    Debug.LogError("Dont have asset dependences config");
                }

                www.assetBundle.Unload(true);
            }
            else
            {
                ResourcesAssetManager.InitializeAssetManager();
            }

            TimerHelper.AddTimer((uint)AssetLoadConfig.CheckAssetReferenceDeltaTime, AssetLoadConfig.CheckAssetReferenceDeltaTime, AssetManager.Instance.CheckExpiredAssets);
            LoadingUI.Instance.SetLoadingBarProgressDelta(1);
        }
Example #6
0
        public ResponseMessage AppendEntry(AppendEntriesMessage message)
        {
            try
            {
                TimerHelper.PauseTimer(ElectionTimer);
                //1.Reply false if term < currentTerm
                if (message.Term < this.term)
                {
                    return(new ResponseMessage(this.term, false, message.SharedId, this.FollowerLog.CommitIndex));
                }
                this.term = message.Term;
                try
                {
                    this.FollowerLog.AppendNewEntries(message.Entry);
                }
                catch (Exception ex) {}

                leaderUrl = message.url;
                //Restart timer to a new random value
                TimerHelper.RestartTimer(GetElectionTimeout(), ElectionTimer);

                return(new ResponseMessage(this.term, true, message.SharedId, this.FollowerLog.CommitIndex));
            }
            catch (Exception ec) {}
            return(new ResponseMessage(this.term, true, message.SharedId, this.FollowerLog.CommitIndex));
        }
Example #7
0
        public static void ScheduleJob(string id, DateTime startTime, IntervalType intervalType, int interval = 1)
        {
            var startTimer = TimerHelper.GetInitialTimer(startTime);
            var scheduler  = _schedulerFactory.New(id, startTimer);

            scheduler.Timer.Elapsed += (sender, e) => _eventHandler.HandleStartEvent(id, SchedulerType.Parent, intervalType, interval);
        }
Example #8
0
        public void OnKeyUp(KeyboardEventArgs e)
        {
            if (keyPressState.Count == 99)
            {
                keyPressState = new PressState();
                TimerHelper.Stop();
                return;
            }

            string a = e.Key.ToLower();

            if (a.Contains("arrow"))
            {
                MoveDirection CurrDirection = StringToDirection(a.Replace("arrow", null));



                //if (keyPressState.Direction == MoveDirection.undefined)
                //{
                if (!e.CtrlKey)
                {
                    SelectNeightbourCell(CurrDirection);
                }
                //}
                //else
                //{
                //    if (CurrDirection == keyPressState.Direction && keyPressState.Count > 0)
                //    {
                //        SelectNeightbourCell(CurrDirection);
                //    }
                //}
            }
        }
Example #9
0
    void Start()
    {
        lightSource = GetComponent <Light2D>();
        lightAlpha  = lightSource.color.a;

        timer = TimerHelper.Create();
    }
Example #10
0
 /// <summary>
 /// 重写单击事件 实现按钮双击
 /// </summary>
 /// <param name="e"></param>
 protected override void OnClick(EventArgs e)
 {
     base.OnClick(e);
     if (isClicked)
     {
         TimeSpan span = DateTime.Now - clickTime;
         if (span.Milliseconds < SystemInformation.DoubleClickTime)
         {
             DoubleClick(this, e);
             isClicked = false;
         }
         else
         {
             isClicked = true;
             clickTime = DateTime.Now;
             TimerHelper.SetTimeout(() =>
             {
                 isClicked = false;
             }, SystemInformation.DoubleClickTime * 2);
         }
     }
     else
     {
         isClicked = true;
         clickTime = DateTime.Now;
         TimerHelper.SetTimeout(() =>
         {
             isClicked = false;
         }, SystemInformation.DoubleClickTime * 2);
     }
 }
Example #11
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _logger.LogDebug("UpdateDailyCurrencyReportTask is starting.");

            stoppingToken.Register(() => _logger.LogDebug("UpdateDailyCurrencyReportTask background task is stopping."));

            while (!stoppingToken.IsCancellationRequested)
            {
                _logger.LogDebug("UpdateDailyCurrencyReportTask background task is doing background work.");

                var(dueTime, updateTimer) = TimerHelper.GetDueTime(_settings.CurrentValue.UpdateTime);
                if (updateTimer)
                {
                    await Task.Delay(dueTime, stoppingToken);
                }
                else
                {
                    await Update();

                    await Task.Delay(dueTime, stoppingToken);
                }
            }

            _logger.LogDebug("UpdateDailyCurrencyReportTask background task is stopping.");

            await Task.CompletedTask;
        }
Example #12
0
        // ---------------------------------------------------------------------------


        //-------------------------- RAFT SPECIFIC FUNCTIONS -------------------------

        /* Explanation of candidate election system:
         *
         * There are 2 timers running simultaneously.
         * The election timeout timer and a timer to request votes.
         *
         * When a batch of vote requests is sent, the timer does not wait for each response
         * he simply sets a callback for the eventual responses.
         * In this callback we will verify if he already has enough votes to become a leader.
         */

        private void ElectionTimeout(Object source, ElapsedEventArgs e)
        {
            CheckFreeze();

            try
            {
                if (leaderFound)
                {
                    return;
                }
                System.Console.WriteLine("(CANDIDATE) Election failed");
                this.term++;
                TimerHelper.PauseTimer(RequestVotesTimer);
                TimerHelper.PauseTimer(ElectionTimer);
                lock (AlreadyVoted)
                {
                    for (int i = 0; i < AlreadyVoted.Count; i++)
                    {
                        AlreadyVoted[i] = false;
                    }
                }

                VotedForMeCount = 1;
                TimerHelper.RestartTimer(GetElectionTimeout(), ElectionTimer);
                TimerHelper.RestartTimer(RequestVotesTimeout, RequestVotesTimer);
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.ToString());
            }
        }
Example #13
0
        public ResponseMessage AppendEntry(AppendEntriesMessage message)
        {
            CheckFreeze();
            if (message.Term < this.term)
            {
                return(new ResponseMessage(this.term, false, message.SharedId));
            }
            this.term = message.Term;

            if (message.LeaderCommit < this.CandidateLog.CommitIndex)
            {
                return(new ResponseMessage(this.term, false, message.SharedId, this.CandidateLog.CommitIndex));
            }
            try
            {
                this.CandidateLog.AppendNewEntries(message.Entry);
            }
            catch (Exception ex) {
            }

            leaderFound = true;
            TimerHelper.StopTimer(ElectionTimer);
            TimerHelper.StopTimer(RequestVotesTimer);
            this.node.SetState(new Follower(this.node, this.term, this.CandidateLog, this.votedFor));

            return(new ResponseMessage(this.term, true, message.SharedId, this.CandidateLog.CommitIndex));
        }
Example #14
0
 private void RetryVoteRequestTimer(Object source, ElapsedEventArgs e)
 {
     CheckFreeze();
     if (DF.N == 1)
     {
         this.node.SetState(new Leader(node, this.term, this.CandidateLog));
     }
     try
     {
         if (leaderFound)
         {
             return;
         }
         TimerHelper.PauseTimer(RequestVotesTimer);
         View v = this.node.manager.RequestView();
         foreach (KeyValuePair <int, Pingable> entry in v.pingables)
         {
             if (!this.AlreadyVoted[entry.Key])
             {
                 RemoteAsyncCallRequestVote(node.otherNodes[entry.Key], new RequestVoteMessage(this.term, this.CandidateLog.LogList.Count, this.node.id, entry.Key));
             }
         }
         TimerHelper.RestartTimer(RequestVotesTimeout, RequestVotesTimer);
     }catch (Exception ex)
     {
         //Console.WriteLine(ex.ToString());
     }
 }
        public Result PostMaintainer([FromBody] IEnumerable <Maintainer> maintainers)
        {
            var acc = maintainers.GroupBy(x => x.Account).Select(y => y.Key);

            if (maintainers.Count() != acc.Count())
            {
                return(Result.GenError <Result>(Error.MaintainerDuplicate));
            }
            //if (maintainers.Any(x => x.Phone.IsNullOrEmpty() || !x.Phone.IsPhone()))
            //{
            //    return Result.GenError<Result>(Error.PhoneError);
            //}
            var cnt = MaintainerHelper.GetCountByAccounts(acc);

            if (cnt > 0)
            {
                return(Result.GenError <Result>(Error.MaintainerIsExist));
            }

            var createUserId = Request.GetIdentityInformation();
            var time         = DateTime.Now;

            foreach (var maintainer in maintainers)
            {
                maintainer.CreateUserId   = createUserId;
                maintainer.MarkedDateTime = time;
                maintainer.Phone          = (maintainer.Phone.IsNullOrEmpty() || !maintainer.Phone.IsPhone()) ? "" : maintainer.Phone;
                maintainer.Remark         = maintainer.Remark ?? "";
            }

            MaintainerHelper.Instance.Add(maintainers);
            TimerHelper.DoMaintainerSchedule();
            return(Result.GenError <Result>(Error.Success));
        }
Example #16
0
        public async Task <JsonResult> PlayACard(string cardString, int roundId, PlayerPosition position, List <string> cardsInHandStrings, bool belaCalled)
        {
            var userId = User.GetUserId();
            var result = await _gameService.PlayACard(cardString, roundId, userId, position, cardsInHandStrings, belaCalled);

            if (result.IsSucessfull)
            {
                var gameId     = result.Values[0] as string;
                var isGameOver = result.Values[2] as bool?;
                await _gameHubContext.Clients.Group("Game" + gameId).SendAsync("CardPlayed", result.Values[1]);

                if (isGameOver.Value)
                {
                    TimerHelper.RemoveTimerForGameId(Convert.ToInt32(gameId));
                    await _lobbyHubContext.Clients.All.SendAsync("UpdateRoomList");
                }
                else
                {
                    var timer = TimerHelper.GetTimerForGameId(Convert.ToInt32(gameId));
                    if (timer != null)
                    {
                        timer.Restart();
                    }
                }

                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { error = result.Errors[0] }));
            }
        }
        public Result PostMaintainerAdjust([FromBody] IEnumerable <MaintainerAdjust> maintainers)
        {
            if (maintainers.Any(x => x.MaintainerId == 0 || x.StartTime == default(DateTime) || x.EndTime == default(DateTime)))
            {
                return(Result.GenError <Result>(Error.MaintainerNotExist));
            }

            var ids = maintainers.Select(x => x.MaintainerId);
            var cnt = MaintainerHelper.Instance.GetCountByIds(ids);

            if (cnt < maintainers.Count())
            {
                return(Result.GenError <Result>(Error.MaintainerNotExist));
            }

            var createUserId = Request.GetIdentityInformation();
            var time         = DateTime.Now;

            foreach (var maintainer in maintainers)
            {
                maintainer.CreateUserId   = createUserId;
                maintainer.MarkedDateTime = time;
                maintainer.Remark         = maintainer.Remark ?? "";
            }

            var sql =
                "INSERT INTO `maintainer_adjust` (`CreateUserId`, `MarkedDateTime`, `Type`, `MaintainerId`, `Remark`, `StartTime`, `EndTime`) " +
                "VALUES (@CreateUserId, @MarkedDateTime, @Type, @MaintainerId, @Remark, @StartTime, @EndTime);";

            ServerConfig.ApiDb.Execute(sql, maintainers);

            TimerHelper.DoMaintainerSchedule();
            return(Result.GenError <Result>(Error.Success));
        }
        void Update()
        {
            if (timer.Get() > timerRequired)
            {
                GameObject fruit = Instantiate(FruitSlicerGameManager.instance.fruits[Random.Range(0, FruitSlicerGameManager.instance.fruits.Length)]);

                fruit.transform.parent = FruitSlicerGameManager.instance.transform;

                double rotation = Vector2D.Atan2(pair.B, pair.A);
                float  distance = (float)Vector2D.Distance(pair.A, pair.B);

                Vector3 newPosition = pair.A.ToVector2() + Vector2D.RotToVec(rotation).ToVector2() * Random.Range(0, distance);
                newPosition.z = Random.Range(0, 30);

                fruit.transform.position = newPosition;
                fruit.transform.rotation = Quaternion.Euler(0, 0, Random.Range(0, 360));

                Rigidbody2D rb = fruit.GetComponent <Rigidbody2D>();
                rb.AddForce(new Vector2(0, 500));
                rb.AddTorque(Random.Range(-100, 100));

                timer         = TimerHelper.Create();
                timerRequired = Random.Range(0.2f, 1);
            }
        }
Example #19
0
    IEnumerator WaitThenFade()
    {
        perfect = true;
        SetAlpha(1);
        System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
        BaseGameManager.Manager.OnGamePaused.AddListener((paused) => TimerHelper.ToggleTimer(timer, paused));
        Coroutine co = StartCoroutine(TimerHelper.DisableIfPaused(timer));

        timer.Start();


        while (timer.Elapsed.TotalSeconds < secondsToStayPerfect)
        {
            yield return(null);
        }

        timer.Reset();
        timer.Start();

        perfect = false;

        while (timer.Elapsed.TotalSeconds < secondsToFade)
        {
            SetAlpha(Mathf.Lerp(1, 0, (float)timer.Elapsed.TotalSeconds / secondsToFade));
            yield return(null);
        }

        //TODO: What happens to this when the game ends?
        BaseGameManager.Manager.OnGamePaused.RemoveListener((paused) => TimerHelper.ToggleTimer(timer, paused));
        StopCoroutine(co);

        BaseGameManager.Manager.OnResetPlayerCombo.Invoke();
        gameObject.SetActive(false);
    }
Example #20
0
        public ResponseMessage RequestVote(RequestVoteMessage message)
        {
            CheckFreeze();
            if (message.Term < this.term)
            {
                return(new ResponseMessage(this.term, false, message.SharedId));
            }
            else if (message.Term == this.term && message.LogSize > this.FollowerLog.LogList.Count)
            {
                return(new ResponseMessage(this.term, true, message.SharedId));
            }
            this.term = message.Term;
            lock (votedFor)
            {
                if (!this.votedFor.ContainsKey(this.term))
                {
                    this.votedFor.Add(this.term, null);
                }
                if (votedFor[this.term] == null || message.CandidateId.Equals(votedFor[this.term]))
                {
                    votedFor[this.term] = message.CandidateId;
                    Console.WriteLine("Voted for: " + message.CandidateId + " " + this.term);
                    TimerHelper.RestartTimer(GetElectionTimeout(), ElectionTimer);
                    return(new ResponseMessage(this.term, true, message.SharedId));
                }
            }
            TimerHelper.RestartTimer(GetElectionTimeout(), ElectionTimer);

            return(new ResponseMessage(this.term, false, message.SharedId));
        }
Example #21
0
        /// <summary>
        /// Immediately disables session, event, exceptions & user details tracking and clears any stored sessions, events, exceptions & user details data.
        /// This API is useful if your app has a tracking opt-out switch, and you want to immediately
        /// disable tracking when a user opts out. Call StartSession to enable logging again
        /// </summary>
        public static async void Halt()
        {
            lock (sync)
            {
                ServerUrl = null;
                AppKey    = null;

                if (Timer != null)
                {
                    Timer.Dispose();
                    Timer = null;
                }

                if (UserDetails != null)
                {
                    UserDetails.UserDetailsChanged -= OnUserDetailsChanged;
                }

                Events.Clear();
                Sessions.Clear();
                Exceptions.Clear();
                breadcrumb  = String.Empty;
                UserDetails = new CountlyUserDetails();
            }

            await Storage.DeleteFile(eventsFilename);

            await Storage.DeleteFile(sessionsFilename);

            await Storage.DeleteFile(exceptionsFilename);

            await Storage.DeleteFile(userDetailsFilename);
        }
Example #22
0
        /// <summary>
        /// This is called after the node is connected to NATS.
        /// </summary>
        protected override void OnConnectNode()
        {
            Logger.Debug(Strings.ConnectedLogMessage, ServiceDescription());

            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectProvision, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnProvision));
            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectUnprovision, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnUnprovision));
            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectBind, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnBind));
            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectUnbind, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnUnbind));
            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectRestore, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnRestore));

            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectDiscover, this.ServiceName()), new SubscribeCallback(this.OnDiscover));

            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectDisableInstance, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnDisableInstance));
            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectEnableInstance, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnEnableInstance));
            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectImportInstance, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnImportInstance));
            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectCleanupNfs, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnCleanupNfs));

            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectCheckOrphan, this.ServiceName()), new SubscribeCallback(this.OnCheckOrphan));
            NodeNats.Subscribe(string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectPurgeOrphan, this.ServiceName(), this.nodeId), new SubscribeCallback(this.OnPurgeOrphan));

            SendNodeAnnouncement();

            TimerHelper.RecurringCall(
                30000,
                delegate
            {
                SendNodeAnnouncement();
            });
        }
Example #23
0
        public async Task <JsonResult> MakeACall(List <string> cardStrings, int roundId, bool isCall)
        {
            var userId = User.GetUserId();
            var result = await _gameService.MakeACall(cardStrings, roundId, userId, isCall);

            if (result.IsSucessfull)
            {
                var gameId = result.Values[0] as string;
                if (isCall)
                {
                    await _gameHubContext.Clients.Group("Game" + gameId).SendAsync("CallMade", result.Values[1]);
                }
                else
                {
                    await _gameHubContext.Clients.Group("Game" + gameId).SendAsync("TurnPassed", result.Values[1]);
                }

                var timer = TimerHelper.GetTimerForGameId(Convert.ToInt32(gameId));
                if (timer != null)
                {
                    timer.Restart();
                }

                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { error = result.Errors[0] }));
            }
        }
Example #24
0
        protected override void OnStart(string[] args)
        {
            try
            {
                log.Info("BatchJob Service Start");
                container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));

                timer          = new System.Timers.Timer();
                timer.Interval = Convert.ToDouble(TimerHelper.GetInterval(Settings.Default.IntervalType, 1));
                timer.Enabled  = true;
                timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);

                leanEngineTimer          = new System.Timers.Timer();
                leanEngineTimer.Interval = Convert.ToDouble(TimerHelper.GetInterval(Settings.Default.IntervalType, 1));
                leanEngineTimer.Enabled  = true;
                leanEngineTimer.Elapsed += new System.Timers.ElapsedEventHandler(leanEngineTimer_Elapsed);

                receiveWOTimer          = new System.Timers.Timer();
                receiveWOTimer.Interval = Convert.ToDouble(TimerHelper.GetInterval(Settings.Default.IntervalType, 1));
                receiveWOTimer.Enabled  = true;
                receiveWOTimer.Elapsed += new System.Timers.ElapsedEventHandler(receiveWOTimer_Elapsed);
            }
            catch (Exception ex)
            {
                log.Error("BatchJob Service Start Failure", ex);
            }
        }
 private void CheckOnline()
 {
     TimerHelper.SetInterval(() =>
     {
         try
         {
             List <string> serviceNames = GetAllServiceNames();
             serviceNames?.ForEach(aServiceName =>
             {
                 List <string> serviceUrls = GetServiceUrls(aServiceName);
                 serviceUrls?.ForEach(aServiceUrl =>
                 {
                     IBaseWcfMSService aService = GetService <IBaseWcfMSService>(aServiceUrl);
                     Task task = Task.Factory.StartNew(() =>
                     {
                         try
                         {
                             bool isOnline = aService.IsOnline();
                         }
                         catch
                         {
                         }
                     });
                     if (!task.Wait(100))
                     {
                         RemoveServiceUrl(aServiceName, aServiceUrl);
                     }
                 });
             });
         }
         catch
         {
         }
     }, new TimeSpan(0, 0, 1));
 }
    void SlicerEvent(Slice2D slice)
    {
        if (timer.GetMillisecs() < 15)
        {
            return;
        }

        if (clip == null)
        {
            return;
        }

        timer = TimerHelper.Create();

        GameObject sound = new GameObject();

        sound.name = "Slicer2D Sound";

        AudioSource audio = sound.AddComponent <AudioSource>();

        audio.clip    = clip;
        audio.enabled = false;
        audio.enabled = true;

        sound.AddComponent <DestroyTimer>();
    }
Example #27
0
            public void Set(long newDueTime)
            {
#if NETSTANDARD1_3
                this.dueTime = TimerHelper.Set(this.GetSafeWaitHandle(), newDueTime);
#else
                this.dueTime = TimerHelper.Set(this.SafeWaitHandle, newDueTime);
#endif
            }
Example #28
0
            public WaitableTimer()
            {
#if NETSTANDARD1_3
                this.SetSafeWaitHandle(TimerHelper.CreateWaitableTimer());
#else
                this.SafeWaitHandle = TimerHelper.CreateWaitableTimer();
#endif
            }
Example #29
0
 protected override void SessionTimerStop()
 {
     if (Timer != null)
     {
         Timer.Dispose();
         Timer = null;
     }
 }
Example #30
0
    void Awake()
    {
        count += 1;

        bufferList.Add(this);

        timer = TimerHelper.Create();
    }