Beispiel #1
0
        void BotTurn()
        {
            button1.Enabled = false;
            var emptyCells = new List <int>();

            for (int i = 0; i < 9; i++)
            {
                if (cellData[i] == EMPTY_CHAR)
                {
                    emptyCells.Add(i);
                }
            }
            var rnd         = new Random();
            var indexInList = rnd.Next(emptyCells.Count);
            var realIndex   = emptyCells.ElementAt(indexInList);

            cellData[realIndex] = AI_CHAR;
            // genius...
            var tcb = new System.Threading.TimerCallback((x) => {
                cells[realIndex].Text = AI_CHAR.ToString();
                var result            = CheckField();
                ParseResult(result);
                button1.Enabled = true;
            });
            var t = new System.Threading.Timer(tcb, null, new Random().Next(200, 501), System.Threading.Timeout.Infinite);
        }
Beispiel #2
0
        private void mnu_Reg_001_Click(object sender, EventArgs e)
        {
            System.Threading.TimerCallback tmp = new System.Threading.TimerCallback(doSomething);
            Gloval.timer = new System.Threading.Timer(tmp, null, 0, 0);

            this.Controls.Remove(currentForm);
            setForm(new BM_Reg_001());
            this.Controls.Add(currentForm);

            /*
             * Bm_Reg_001 reg001 = new Bm_Reg_001();
             *
             * if (formIsExist(reg001.GetType()))
             * {
             *  reg001.Dispose();     // 창 리소스 제거
             * }
             * else
             * {
             *  reg001.MdiParent = this;
             *  reg001.Show();
             * }
             *
             * */
            this.Cursor = Cursors.Default;
        }
Beispiel #3
0
        /// <summary>
        /// ProgUpdateMessage のコンストラクタ
        /// </summary>
        public ProgUpdateMessage(Rectangle mainFormRectangle, string messVersion, int autoWindowCloseTime)
        {
            try
            {
                InitializeComponent();

                this.mainFormRectangle = mainFormRectangle;

                string[] messVersions = messVersion.Split(',');
                labelVersionMessage.Text = messVersions[0];
                if (2 <= messVersions.Length)
                {
                    toolTip.SetToolTip(labelVersionMessage, messVersions[1]);
                }

                // 自動ウィンドウ クローズ用のタイマ
                if (autoWindowCloseTime != 0)
                {
                    System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(OnTimerAutoWindowClose);
                    timerAutoWindowClose = new System.Threading.Timer(timerDelegate, null, System.Threading.Timeout.Infinite, 0);
                    timerAutoWindowClose.Change(autoWindowCloseTime * 1000, System.Threading.Timeout.Infinite);                         // SetTimer(周期的なシグナル通知は無効)
                }
            }
            catch (Exception exp)
            {
                Debug.WriteLine(exp.Message);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Start a thread for output.
 /// </summary>
 private void OutputThread()
 {
     //  Create a TimerCallback, it will run OutputCacheLogs(Object)
     this.timerDelegate = new System.Threading.TimerCallback(OutputCachedLogs);
     //  Create the Timer Class, to set the TimerCallback will run every ConstCacheTimeInterval millisecond.
     this.timer = new System.Threading.Timer(timerDelegate, null, ConstCacheTimeInterval, ConstCacheTimeInterval);
 }
Beispiel #5
0
        //private static ConcurrentDictionary<long, Level> m_vInMemoryPlayers { get; set; }

        public ObjectManager()
        {
            m_vTimerCanceled = false;
            m_vDatabase      = new DatabaseManager();
            NpcLevels        = new Dictionary <int, string>();
            DataTables       = new DataTables();
            m_vAlliances     = new Dictionary <long, Alliance>();

            if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
            {
                LoadFingerPrint();
            }

            using (StreamReader sr = new StreamReader(@"gamefiles/default/home.json"))
            {
                m_vHomeDefault = sr.ReadToEnd();
            }

            m_vAvatarSeed   = m_vDatabase.GetMaxPlayerId() + 1;
            m_vAllianceSeed = m_vDatabase.GetMaxAllianceId() + 1;
            LoadGameFiles();
            LoadNpcLevels();

            System.Threading.TimerCallback TimerDelegate = new System.Threading.TimerCallback(Save);
            System.Threading.Timer         TimerItem     = new System.Threading.Timer(TimerDelegate, null, 60000, 60000);
            TimerReference = TimerItem;

            Console.WriteLine("Database Sync started");
            m_vRandomSeed = new Random();
        }
 public void Start()
 {
     HasStarted = false;
     System.Threading.TimerCallback callback = new System.Threading.TimerCallback(this.Begin);
     timer = new System.Threading.Timer(callback, null, 1, 1000);
     return;
 }
Beispiel #7
0
 private void CreateTimer(System.Threading.TimerCallback callback, int interval, ref System.Threading.Timer timer)
 {
     if (timer == null)
     {
         timer = new System.Threading.Timer(callback, null, 0, interval);
     }
 }
        //private static ConcurrentDictionary<long, Level> m_vInMemoryPlayers { get; set; }

        public ObjectManager()
        {
            m_vTimerCanceled = false;
            m_vDatabase = new DatabaseManager();
            NpcLevels = new Dictionary<int, string>();
            DataTables = new DataTables();
            m_vAlliances = new Dictionary<long, Alliance>();

            if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
            {
                LoadFingerPrint();
            }

            using (StreamReader sr = new StreamReader(@"gamefiles/default/home.json"))
            {
                m_vHomeDefault = sr.ReadToEnd();
            }

            m_vAvatarSeed = m_vDatabase.GetMaxPlayerId() + 1;
            m_vAllianceSeed = m_vDatabase.GetMaxAllianceId() + 1;
            LoadGameFiles();
            LoadNpcLevels();

            System.Threading.TimerCallback TimerDelegate = new System.Threading.TimerCallback(Save);
            System.Threading.Timer TimerItem = new System.Threading.Timer(TimerDelegate, null, 60000, 60000);
            TimerReference = TimerItem;

            Console.WriteLine("Database Sync started");
            m_vRandomSeed = new Random();
        }
Beispiel #9
0
        internal NodeGroup(RelayNodeGroupDefinition groupDefinition, RelayNodeConfig nodeConfig, ForwardingConfig forwardingConfig)
        {
            GroupDefinition   = groupDefinition;
            Activated         = groupDefinition.Activated;
            _clusterByRange   = groupDefinition.UseIdRanges;
            _forwardingConfig = forwardingConfig;

            RelayNodeClusterDefinition myClusterDefinition = NodeManager.Instance.GetMyNodeClusterDefinition();

            foreach (RelayNodeClusterDefinition clusterDefintion in groupDefinition.RelayNodeClusters)
            {
                NodeCluster nodeCluster = new NodeCluster(clusterDefintion, nodeConfig, this, forwardingConfig);
                if (clusterDefintion == myClusterDefinition)
                {
                    MyCluster = nodeCluster;
                }
                Clusters.Add(nodeCluster);
            }

            _nodeReselectTimerCallback = new System.Threading.TimerCallback(NodeReselectTimer_Elapsed);
            if (_nodeReselectTimer == null)
            {
                _nodeReselectTimer = new System.Threading.Timer(_nodeReselectTimerCallback);
            }
            _nodeReselectTimer.Change(NodeReselectIntervalMilliseconds, NodeReselectIntervalMilliseconds);

            QueueTimerCallback = new System.Threading.TimerCallback(QueueTimer_Elapsed);
            if (QueueTimer == null)
            {
                QueueTimer = new System.Threading.Timer(QueueTimerCallback);
            }
            QueueTimer.Change(DequeueIntervalMilliseconds, DequeueIntervalMilliseconds);
        }
Beispiel #10
0
		internal NodeGroup(RelayNodeGroupDefinition groupDefinition, RelayNodeConfig nodeConfig, ForwardingConfig forwardingConfig)
		{   
			GroupDefinition = groupDefinition;
			Activated = groupDefinition.Activated;
			_clusterByRange = groupDefinition.UseIdRanges;
			_forwardingConfig = forwardingConfig;
			NodeSelectionHopWindowSize = groupDefinition.NodeSelectionHopWindowSize;
			RelayNodeClusterDefinition myClusterDefinition = NodeManager.Instance.GetMyNodeClusterDefinition();

			foreach (RelayNodeClusterDefinition clusterDefintion in groupDefinition.RelayNodeClusters)
			{
				NodeCluster nodeCluster = new NodeCluster(clusterDefintion, nodeConfig, this, forwardingConfig);
				if (clusterDefintion == myClusterDefinition)
				{
					MyCluster = nodeCluster;
				}
				Clusters.Add(nodeCluster);
			}

			_nodeReselectTimerCallback = new System.Threading.TimerCallback(NodeReselectTimer_Elapsed);
			if (_nodeReselectTimer == null)
			{
				_nodeReselectTimer = new System.Threading.Timer(_nodeReselectTimerCallback);
			}
			_nodeReselectTimer.Change(NodeReselectIntervalMilliseconds, NodeReselectIntervalMilliseconds);

			QueueTimerCallback = new System.Threading.TimerCallback(QueueTimer_Elapsed);
			if (QueueTimer == null)
			{
				QueueTimer = new System.Threading.Timer(QueueTimerCallback);
			}
			QueueTimer.Change(DequeueIntervalMilliseconds, DequeueIntervalMilliseconds);
		}
Beispiel #11
0
        /// <summary>
        /// Set the output thread. If the Output Setting have the output, it will start a thread to run the OutputCacheLogs function.
        /// </summary>
        private void OutputThread()
        {
            //  If the Output Setting have the output.
            if ((_OutputSetting != LoggerOutputSetting.NotWriteToFileRegular) &&
                (_OutputSetting != LoggerOutputSetting.NotWriteToFileRTF))
            {
                AddLog("Start a Thread to execute the output.", "Logger::OutputThread()", LogType.Debug);

                //  Create a TimerCallback, it will run OutputCacheLogs(Object)
                timerDelegate = new System.Threading.TimerCallback(OutputCacheLogs);
                //  Create the Timer Class, to set the TimerCallback will run every ConstCacheTimeInterval millisecond.
                timer = new System.Threading.Timer(timerDelegate, null, ConstCacheTimeInterval, ConstCacheTimeInterval);

                AddLog("Start a Thread to execute the output Succeed.", "Logger::OutputThread()", LogType.Debug);
            }
            else
            {
                //  Close the Thread
                if (timer != null)
                {
                    timer.Dispose();
                }
                timerDelegate = null;

                AddLog("Close the output Thread.", "Logger::OutputThread()", LogType.Debug);
            }
        }
Beispiel #12
0
        public SystemTray()
        {
            //constructor for the form
            InitializeComponent();

            //keep the form hidden
            this.Hide();
            WSNotifyIcon.Icon    = mDirIcon;
            WSNotifyIcon.Text    = "Monitoring scheduled tasks";
            WSNotifyIcon.Visible = true;

            //Create the MenuItem objects and add them to
            //the context menu of the NotifyIcon.
            MenuItem[] mnuItems = new MenuItem[1];

            //create the menu items array
            mnuItems[0]             = new MenuItem("Quit monitoring", new EventHandler(this.ExitControlForm));
            mnuItems[0].DefaultItem = true;

            //add the menu items to the context menu of the NotifyIcon
            ContextMenu notifyIconMenu = new ContextMenu(mnuItems);

            WSNotifyIcon.ContextMenu = notifyIconMenu;

            // creates a timer call back to be called whenever the timer is ready to go
            System.Threading.TimerCallback tc = new System.Threading.TimerCallback(OnCheckTimerEvent);

            // set the last checked time into the past to catch tasks that ran recently
            // say 60 minutes
            _lastCheck = DateTime.Now.AddMinutes(-60);
            // the timer itself
            _checkTimer = new System.Threading.Timer(tc, null, 0, WaitTime);
        }
Beispiel #13
0
        public void RunTimer()
        {
            StateObjClass StateObj = new StateObjClass();

            StateObj.TimerCanceled = false;
            StateObj.SomeValue     = 1;
            System.Threading.TimerCallback TimerDelegate =
                new System.Threading.TimerCallback(TimerTask);

            // Create a timer that calls a procedure every 2 seconds.
            // Note: There is no Start method; the timer starts running as soon as
            // the instance is created.
            System.Threading.Timer TimerItem =
                new System.Threading.Timer(TimerDelegate, StateObj, 2000, 2000);

            // Save a reference for Dispose.
            StateObj.TimerReference = TimerItem;

            // Run for ten loops.
            while (StateObj.SomeValue < 10)
            {
                // Wait one second.
                System.Threading.Thread.Sleep(1000);
            }

            // Request Dispose of the timer object.
            StateObj.TimerCanceled = true;
        }
 public void Start()
 {
     HasStarted = false;
     System.Threading.TimerCallback callback = new System.Threading.TimerCallback(this.Begin);
     timer = new System.Threading.Timer(callback, null, 1, 1000);
     return;
 }
Beispiel #15
0
        protected override void OnStart(string[] args)
        {
            GetApplicationParameters();
            oMetier = new oMetier(Log);

            timerDelegate = new System.Threading.TimerCallback(ConnectToNodeJsServer);
            serviceTimer  = new System.Threading.Timer(timerDelegate, null, 1000, System.Threading.Timeout.Infinite);
        }
Beispiel #16
0
 protected TimerBase(SerializationInfo info, StreamingContext context)
 {
     _id = (TimerId)info.GetValue("id", typeof(TimerId));
     _startTime = (Time?)info.GetValue("t", typeof(Time?));
     _interval = (Minute)info.GetValue("i", typeof(Minute));
     _schedules = (Dictionary<Minute, Action>)info.GetValue("s", typeof(Dictionary<Minute, Action>));
     _timerDelegate = new TimerCallback(this.Execute);
 }
Beispiel #17
0
 private void wndMain_Activated(object sender, EventArgs e)
 {
     if (_initTimer == null)
     {
         System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(this.Init);
         _initTimer = new System.Threading.Timer(timerDelegate, null, 0, 100);
     }
 }
Beispiel #18
0
        private TimeControl()
        {
            t = new Stopwatch();
            t.Start();

            System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(tkTime);
            timerItem = new System.Threading.Timer(timerDelegate, null, 100, 100);
            sysCount  = 0;
        }
Beispiel #19
0
 /// <summary>
 /// 定时执行
 /// </summary>
 /// <param name="fn">执行函Number void fn(object o)</param>
 /// <param name="v">fn 的传入参Number</param>
 /// <param name="initialDelay">执行时间:从curr时间延后执行</param>
 /// <param name="delay">间隔执行时间</param>
 /// <returns></returns>
 public static System.Threading.Timer schedule(System.Threading.TimerCallback fn, object v, long initialDelay, long delay)
 {
     System.Threading.Timer         timer = null;
     System.Threading.TimerCallback tc    = new System.Threading.TimerCallback((o) => {
         fn(v);
     });
     timer = new System.Threading.Timer(tc, null, initialDelay, delay);
     return(timer);
 }
Beispiel #20
0
        public Timer(TimeSpan interval)
        {
            var state = new TimerState();

            var timerDelegate = new System.Threading.TimerCallback(Tick);
            var timer         = new System.Threading.Timer(timerDelegate, state, TimeSpan.FromSeconds(0), interval);

            state.Timer = timer;
        }
Beispiel #21
0
 protected TimerBase(Uri uri)
 {
     if(null == uri)
         throw new ArgumentNullException("uri");
     _id = new TimerId(uri.ToString());
     _schedules = new Dictionary<Minute, Action>();
     _timers = new Dictionary<Minute, ThreadingTimer>();
     _timerDelegate = new TimerCallback(this.Execute);
 }
Beispiel #22
0
        private void clickReg(object sender, EventArgs e)
        {
            System.Threading.TimerCallback tmp = new System.Threading.TimerCallback(doSomething);
            Gloval.timer = new System.Threading.Timer(tmp, null, 0, 0);

            this.Controls.Remove(currentForm);
            setForm(new BM_Reg_001());
            this.Controls.Add(currentForm);
        }
Beispiel #23
0
        System.Threading.Timer timerItem; // タスク実行タイマ

        #endregion Fields

        #region Constructors

        private TimeControl()
        {
            t = new Stopwatch();
            t.Start();

            System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(tkTime);
            timerItem = new System.Threading.Timer(timerDelegate, null, 100, 100);
            sysCount = 0;
        }
Beispiel #24
0
        static int Main(string[] args)
        {
            PrintHeader();
            if (args.Length == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Please enter the file you want to process.");
                Console.WriteLine("Usage: CountingWordsConsole <filename>");
                Console.WriteLine(@"");
                Console.ResetColor();
                return(1);
            }
            StateTimeClass StateObj = new StateTimeClass();

            StateObj.Canceled = false;
            StateObj.handler  = new PerformanceHandler();
            StateObj.Value    = 1;
            System.Threading.TimerCallback TimerDelegate = new System.Threading.TimerCallback(TimerTask);

            // Create a timer that calls a procedure every 200ms
            // Note: There is no Start method; the timer starts running as soon as
            // the instance is created.
            System.Threading.Timer TimerItem = new System.Threading.Timer(TimerDelegate, StateObj, 100, 100);

            // Save a reference for Dispose.
            StateObj.Reference = TimerItem;

            Reducer reducer = new Reducer();

            try
            {
                SystemDetails.ShowCPUDetails();
                Stopwatch sw       = new Stopwatch();
                string    readText = File.ReadAllText(args[0]);
                Console.WriteLine("Starting reduction");
                sw.Start();
                reducer.MapReduce(readText);
                sw.Stop();
                Console.WriteLine("Reduction completed");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Elapsed={0}", sw.Elapsed);
                File.WriteAllText("Results.txt", reducer.SortedResults().ToString());
                Console.WriteLine("Done!, processing {0:D} words", reducer.Numwords.ToString("N", CultureInfo.InvariantCulture));
                Console.WriteLine("Please review Results.txt");
                Console.ResetColor();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            // Request Dispose of the timer object.
            StateObj.Canceled = true;

            return(0);
        }
Beispiel #25
0
 public ActionResult start(ArgBag arg)
 {
     if (!bStarted)
     {
         System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(main);
         threadTimer = new System.Threading.Timer(timerDelegate, null, dueTime, period);
         bStarted    = true;
     }
     return(View());
 }
Beispiel #26
0
 public ActionResult start(ArgBag arg)
 {
     if (!bStarted)
     {
         System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(main);
         threadTimer = new System.Threading.Timer(timerDelegate, null, dueTime, period);
         bStarted = true;
     }
     return View();
 }
Beispiel #27
0
 public ModifierClass(string fileName, EventHandler findWindoweventHandler)
 {
     FileName      = fileName;
     handler       = findWindoweventHandler;
     ProcessWriter = new ProcessWriter();
     InitailzeSoftWare();
     TimerCallback = TryToFindWindow;
     Timer         = new System.Threading.Timer(TimerCallback);
     Timer.Change(intervalFindTime, 0);
 }
Beispiel #28
0
        static int Main(string[] args)
        {
            PrintHeader();
            if (args.Length == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Please enter the file you want to process.");
                Console.WriteLine("Usage: CountingWordsConsole <filename>");
                Console.WriteLine(@"");
                Console.ResetColor();
                return 1;
            }
            StateTimeClass StateObj = new StateTimeClass();
            StateObj.Canceled = false;
            StateObj.handler = new PerformanceHandler();
            StateObj.Value = 1;
            System.Threading.TimerCallback TimerDelegate = new System.Threading.TimerCallback(TimerTask);

            // Create a timer that calls a procedure every 200ms
            // Note: There is no Start method; the timer starts running as soon as
            // the instance is created.
            System.Threading.Timer TimerItem = new System.Threading.Timer(TimerDelegate, StateObj, 100, 100);

            // Save a reference for Dispose.
            StateObj.Reference = TimerItem;

            Reducer reducer = new Reducer();
            try
            {
                SystemDetails.ShowCPUDetails();
                Stopwatch sw = new Stopwatch();
                string readText = File.ReadAllText(args[0]);
                Console.WriteLine("Starting reduction");
                sw.Start();
                reducer.MapReduce(readText);
                sw.Stop();
                Console.WriteLine("Reduction completed");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Elapsed={0}", sw.Elapsed);
                File.WriteAllText("Results.txt", reducer.SortedResults().ToString());
                Console.WriteLine("Done!, processing {0:D} words", reducer.Numwords.ToString("N", CultureInfo.InvariantCulture));
                Console.WriteLine("Please review Results.txt");
                Console.ResetColor();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            // Request Dispose of the timer object.
            StateObj.Canceled = true;

            return 0;
        }
        public HoverController()
        {
            enabled = true;
            hoverItem = null;
            showingTooltip = false;
            rectHelper = new RectangleHelper(Color.FromArgb(120, 192, 192, 192), Color.White);
            hoverPainter = new HoverPainter();

            timerDelegate = new System.Threading.TimerCallback(timerCallback);
            timer = new System.Threading.Timer(timerDelegate, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
        }
Beispiel #30
0
        /// <summary>
        /// Executes when the service starts, initializes the timer
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            // creates a timer call back to be called whenever the timer is ready to go
            System.Threading.TimerCallback tc = new System.Threading.TimerCallback(OnCheckTimerEvent);

            // set the last checked time into the past to catch tasks that ran recently
            // say 60 minutes
            _lastCheck = DateTime.Now.AddMinutes(-60);
            // the timer itself
            _checkTimer = new System.Threading.Timer(tc, null, 0, WaitTime);
        }
Beispiel #31
0
        public TimerStuff()
        {
            // Create the timer callback delegate.
            System.Threading.TimerCallback cb = new System.Threading.TimerCallback(ProcessTimerEvent);

            // Create the object for the timer.
            ClsTime time = new ClsTime();

            // Create the timer. It is autostart, so creating the timer will start it.
            seconds = new System.Threading.Timer(cb, time, 500, 1000);
        }
    TimerStateObjClass stateObj;      //THIS IS THE ORIGINAL STATE OBJ
    internal void SomeMethod()
    {
        stateObj = new TimerStateObjClass();
        stateObj.TimerCanceled = false;
        stateObj.SomeValue     = 100;
        System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(twit.hometimelineclass._sqlUpdateFromTwitterWorker_DoWork);

        var sqlUpdateFromTwitterTimer = new Timer(timerDelegate, stateObj, 0, 20000);

        stateObj.SqlUpdateFromTwitterTimerReference = sqlUpdateFromTwitterTimer;
    }
 private void StartTimer()
 {
     //create the timer for the callback method
     if (!isTimerOn)
     {
         ConvertEggSelectionToTime();
         System.Threading.TimerCallback cb = new System.Threading.TimerCallback(ProcessTimerEvent);
         //Create the object for the timer.
         timerBoiled = new System.Threading.Timer(cb, this, 0, 1000);
     }
 }
Beispiel #34
0
        public HoverController()
        {
            enabled        = true;
            hoverItem      = null;
            showingTooltip = false;
            rectHelper     = new RectangleHelper(Color.FromArgb(120, 192, 192, 192), Color.White);
            hoverPainter   = new HoverPainter();

            timerDelegate = new System.Threading.TimerCallback(timerCallback);
            timer         = new System.Threading.Timer(timerDelegate, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
        }
        public GameplayForm(UDPClientServerCommons.Client.ClientSide clientSide)
        {
            InitializeComponent();

            System.Threading.TimerCallback tc = new System.Threading.TimerCallback(timerCallback);
            gameLoopTimer = new System.Threading.Timer(tc);
            gameLoopTimer.Change(1000, 1000);

            network = clientSide;
            //gameLoopTimer = new System.Threading.Timer(new System.Threading.TimerCallback(timerCallback), null, 0, 1000);
        }
Beispiel #36
0
        static Pooling()
        {
            if (Management.Connection.TimeOutSecond > 0) //不启动
            {
                timerDelegate = new System.Threading.TimerCallback(timer_Tick);

                //从配置文件中读取timer 的执行间隔时间
                int interval = 6000;
                timer = new System.Threading.Timer(timerDelegate, autoEvent, 0, interval);
            }
        }
Beispiel #37
0
        /// <summary>
        /// Write the Cache logs and the Error Cache log to the Regular log file.
        /// </summary>
        private void WriteRegularCacheLogs()
        {
            //  If the Output Setting is not the LoggerOutput.Regular.
            if (_OutputSetting != LoggerOutputSetting.Regular)
            {
                AddLog("The Output is not Regular, output have error.",
                       "Logger::WriteRegularCacheLogs()", LogType.Debug);
                return;
            }

            lock (lockthis)
            {
                AddLog("Lock the list and output the logs.",
                       "Logger::WriteRegularCacheLogs()", LogType.Debug);

                //  When the log cache have items
                if (_LogsCache.Count != 0)
                {
                    try
                    {
                        //  Create a new StreamWriter class to save the logs.
                        StreamWriter writer = new StreamWriter(_LogFilePath + "\\" + ConstLogFileName + ".log", true);

                        foreach (Log _log in _LogsCache)
                        {
                            writer.WriteLine(FormatLogString(_log));
                        }
                        writer.Close();

                        //  Clear cache logs
                        _LogsCache.Clear();
                    }
                    catch (Exception e)
                    {
                        AddLog("The output got some error. Type: " + e.GetType() + ", Message: " + e.Message,
                               "Logger::WriteRegularCacheLogs()", LogType.Debug);

                        _OutputSetting = LoggerOutputSetting.NotWriteToFileRegular;
                        AddLog("Change the output setting to \"NotWriteToFileRegular\".", "Logger::WriteRegularCacheLogs()", LogType.Debug);

                        //  Close the Thread
                        if (timer != null)
                        {
                            timer.Dispose();
                        }
                        timerDelegate = null;
                        AddLog("Close the output Thread.", "Logger::WriteRegularCacheLogs()", LogType.Debug);

                        throw;
                    }
                }
            }
        }
Beispiel #38
0
        public override void Run(BenchmarkParams benchParams)
        {
            base.Run(benchParams);
            var syncContext = System.Threading.SynchronizationContext.Current;

            System.Threading.TimerCallback method = state =>
            {
                syncContext.Post(CheckInPost, null);
            };
            timer = new System.Threading.Timer(method, null, benchParams.TickInterval, benchParams.TickInterval);
            // Starts automatically.
        }
Beispiel #39
0
 public Timer(System.Threading.TimerCallback callback)
 {
     if(!Node.MainNode.Ok()) { //this will also create the mainNode, if needed
         throw new Exception("Cannot use RosTimer without a working Node!");
     }
     this.sig = new System.Threading.AutoResetEvent(false);
     this.callback = callback;
     this.running = true;
     this.paused = true;
     this.t = new System.Threading.Thread(new System.Threading.ThreadStart(this.Run));
     this.t.Start();
 }
Beispiel #40
0
        public DataProcessor()
        {
            System.Threading.TimerCallback cb = new System.Threading.TimerCallback(ProcessData);
            _timerDbLog = new System.Threading.Timer(cb, null, _dbLogTimerDueTime, _dbLogTimerPeriod);
            InitDataTable();

            System.Threading.TimerCallback cba = new System.Threading.TimerCallback(SendToAzure);
            _timerAzure = new System.Threading.Timer(cba, null, _azureTimerDueTime, _azureTimerPeriod);

            _deviceClient = DeviceClient.Create(_iotHubUri,
               AuthenticationMethodFactory.CreateAuthenticationWithRegistrySymmetricKey(_deviceId, _deviceKey), TransportType.Http1);
        }
Beispiel #41
0
 public TimerNotificationInfo(int notificationId, string type, string message, object userData, DateTime date, TimeSpan period, long nbOccurences, bool fixedRate, System.Threading.TimerCallback callback, CheckSendPastNotificationsDelegate sendPastNotifications)
 {
     _notificationId        = notificationId;
     _type                  = type;
     _message               = message;
     _userData              = userData;
     _date                  = date;
     _period                = period;
     _nbOccurences          = nbOccurences;
     _fixedRate             = fixedRate;
     _callback              = callback;
     _sendPastNotifications = sendPastNotifications;
 }
Beispiel #42
0
        public ServerSide(IPEndPoint ServerIp)
            : base(ServerIp)
        {
            base.MessageWasReceivedEvent += new EventHandler(myUdpServer_MessageWasReceivedEvent);
            System.Threading.TimerCallback timerCallback = new System.Threading.TimerCallback(timerCallbackMethod);
            timer = new System.Threading.Timer(timerCallback, null, System.Threading.Timeout.Infinite, _TimerTickPeriod);
            //ackOperating = new AckOperating();

            //diagnostics
            Diagnostic.NetworkingDiagnostics.Configure();

            //counter
            packetIdCounter = new UDPClientServerCommons.Usefull.PacketIdCounter();
        }
        public ActionManager(IActionQueue manager)
        {
            _actionList = new List<ActionListElement>();
            _manager = manager;


#if !WP7
            if (Environment.ProcessorCount == 1)          
#endif
            {
                _actionExecutingRunningNow = true;
                // Create the timer callback delegate.
                System.Threading.TimerCallback cb = new System.Threading.TimerCallback(ProcessTimerEvent);
                _timer = new System.Threading.Timer(cb, manager, 0, 100); //180
            }
        } 
        protected void Page_Load(object sender, EventArgs e)
        {
            inizializeValues();

            Object aObj = new object();
            System.Threading.TimerCallback eDelegate = new System.Threading.TimerCallback(setMessage);

            System.Threading.Timer TimerItem = new System.Threading.Timer(eDelegate, null, 1000,1000);

            while (Intents < 5)
            {
                // Wait one second.
                System.Threading.Thread.Sleep(1000);
            }

            VisualizeStockDetails();
        }
Beispiel #45
0
		public override void Draw (RectangleF rect)
		{
			var width = rect.Width * 15/16;
			var height = rect.Height * 4/10;

			var xPad = (rect.Width - width) / 2;
			var yPad = (rect.Height - height) / 2;

			var viewFinderRect = new RectangleF(xPad, yPad, width, height);

			var cg = UIGraphics.GetCurrentContext();
			cg.ClearRect(viewFinderRect);

			cg.SetFillColor(0.0f, 0.0f, 0.0f, 0.6f);

			cg.FillRect(new RectangleF(0, 0, xPad, rect.Height));
			cg.FillRect(new RectangleF(xPad + width, 0, xPad, rect.Height));

			cg.FillRect(new RectangleF(xPad, 0, width, yPad));
			cg.FillRect(new RectangleF(xPad, yPad + height, width, yPad));

			cg.SetStrokeColor(1.0f, 0.9f);
			cg.SetLineWidth(3.0f);
			cg.StrokeRect(viewFinderRect);
			cg.ClearRect(viewFinderRect);

			//var alpha = rnd.Next(0.5f, 0.9f);
			laserAlpha += 0.1f;

			if (laserAlpha > 0.9f)
				laserAlpha = 0.5f;



			cg.SetFillColor(1.0f, 0.2f, 0.2f, laserAlpha);
			cg.FillRect(new RectangleF(xPad + 1, yPad + (height / 2) - 2, width - 2, 4));

			var tc=	new System.Threading.TimerCallback((o) => {
				
				this.BeginInvokeOnMainThread(() => this.SetNeedsDisplay());

			});
			var t = new System.Threading.Timer(tc, null, 250, System.Threading.Timeout.Infinite);
		
		}
Beispiel #46
0
        public static void RunTimer(int timeOutInSec)
        {
            StateObjClass StateObj = new StateObjClass();
            StateObj.MaxValue = (int) timeOutInSec / 1;
            StateObj.TimerCanceled = false;
            StateObj.SomeValue = 1;
            System.Threading.TimerCallback TimerDelegate =
                new System.Threading.TimerCallback(TimerTask);

            // Create a timer that calls a procedure every 2 seconds. 
            // Note: There is no Start method; the timer starts running as soon as  
            // the instance is created.
            System.Threading.Timer TimerItem =
                new System.Threading.Timer(TimerDelegate, StateObj, 1000, 1000);

            // Save a reference for Dispose.
            StateObj.TimerReference = TimerItem;
        }
Beispiel #47
0
        /// <summary>
        /// The form is ready to be displayed so initialize all of the
        /// splash screen data and draw the first frame.
        /// </summary>
        /// <param name="sender">Sending object</param>
        /// <param name="e">Event arguments</param>
        private void SplashForm_Load(object sender, System.EventArgs e)
        {
            // Make the form full screen
            this.Text = "";
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.ControlBox = false;
            this.FormBorderStyle = FormBorderStyle.None;
            //this.WindowState = FormWindowState.Maximized;
            this.Menu = null;

            // Center the splash screen background
            //splashRegion.X = (Screen.PrimaryScreen.Bounds.Width - bmpSplash.Width) / 2;
            //splashRegion.Y = (Screen.PrimaryScreen.Bounds.Height - bmpSplash.Height) / 2;
            //splashRegion.Width = bmpSplash.Width;
            //splashRegion.Height = bmpSplash.Height;
            splashRegion.X = (Screen.PrimaryScreen.Bounds.Width - bmpAnim[0].Width) /2;
            splashRegion.Y = ((Screen.PrimaryScreen.Bounds.Height - bmpAnim[0].Height) / 2) - 40;
            splashRegion.Width = bmpAnim[0].Width;
            splashRegion.Height = bmpAnim[0].Height;

            // Set up the rectangle from which the background will be drawn
            splashSrc.X = 0;
            splashSrc.Y = 0;
            splashSrc.Width = bmpAnim[0].Width;
            splashSrc.Height = bmpAnim[0].Height;

            // Set up the destination region of the animatino draw
            animPos.X = splashRegion.X - bmpAnim[0].Width / kNumAnimationCells;
            animPos.Y = splashRegion.Y + splashRegion.Height - bmpAnim[0].Height;
            animPos.Width = bmpAnim[0].Width / kNumAnimationCells;
            animPos.Height = bmpAnim[0].Height;

            // Initialize the draw region used to optimize animation updates
            redrawSrc.Width = bmpAnim[0].Width / kNumAnimationCells;
            redrawSrc.Height = bmpAnim[0].Height;

            // Cache the transparent color
            Color c1 = bmpAnim[0].GetPixel(0, 0),
                c2 = bmpAnim[0].GetPixel(0, 0);
            attr.SetColorKey(c1, c2);

            // Create the graphics object and set its clipping region
            g = CreateGraphics();
            g.Clip = new Region(splashRegion);

            // Draw the screen once with the full background update
            // No need to use Application.DoEvents to force OnPaint.
            //Draw(true, false);

            // Start a timer that will call Draw every 200 ms
            System.Threading.TimerCallback splashDelegate = new System.Threading.TimerCallback(this.Draw);
            this.splashTimer = new System.Threading.Timer(splashDelegate, null, timerInterval_ms, timerInterval_ms);
        }
Beispiel #48
0
 public ManagedThreadTimer(int onhold, int time, System.Threading.TimerCallback callback, ManagedThreadPool pool, object obj)
 {
     T = DateTime.Now;
     OnHold = onhold;
     Obj = obj;
     Time = time;
     Callback = callback;
     Pool = pool;
     pool.Add(this);
 }
Beispiel #49
0
        /// <summary>
        /// Set the output thread. If the Output Setting have the output, it will start a thread to run the OutputCacheLogs function.
        /// </summary>
        private void OutputThread()
        {
            //  If the Output Setting have the output.
            if ((_OutputSetting != LoggerOutputSetting.NotWriteToFileRegular)
                && (_OutputSetting != LoggerOutputSetting.NotWriteToFileRTF))
            {
                AddLog("Start a Thread to execute the output.", "Logger::OutputThread()", LogType.Debug);

                //  Create a TimerCallback, it will run OutputCacheLogs(Object)
                timerDelegate = new System.Threading.TimerCallback(OutputCacheLogs);
                //  Create the Timer Class, to set the TimerCallback will run every ConstCacheTimeInterval millisecond.
                timer = new System.Threading.Timer(timerDelegate, null, ConstCacheTimeInterval, ConstCacheTimeInterval);

                AddLog("Start a Thread to execute the output Succeed.", "Logger::OutputThread()", LogType.Debug);
            }
            else
            {
                //  Close the Thread
                if (timer != null)
                    timer.Dispose();
                timerDelegate = null;

                AddLog("Close the output Thread.", "Logger::OutputThread()", LogType.Debug);
            }
        }
Beispiel #50
0
 public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
 {
     System.Threading.Timer Timer;
     if (flags == 0)
     {
         FreezeCache.Add(target.ToString());
         System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
         Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
         Timers.Add(target, Timer);
     }
     else
     {
         FreezeCache.Remove(target.ToString());
         Timers.TryGetValue(target, out Timer);
         Timers.Remove(target);
         Timer.Dispose();
     }
 }
Beispiel #51
0
        void Selected_Serial(object sender, EventArgs e, string selected_port)
        {
            Console.WriteLine("Selected port");
            Console.WriteLine(selected_port);
            Console.ReadLine();
            SelectedSerialPort = new SerialPort(selected_port);
            if ( ! SelectedSerialPort.IsOpen)
            {
                SelectedSerialPort.Open();

            };
            StateObjClass StateObj = new StateObjClass();
            StateObj.TimerCanceled = false;
            System.Threading.TimerCallback TimerDelegate = new System.Threading.TimerCallback(dataCheck);
            System.Threading.Timer TimerItem = new System.Threading.Timer(TimerDelegate, StateObj, 1000, 3000);
            StateObj.TimerReference = TimerItem;
            // SelectedSerialPort.WriteLine("Send Data \n");
        }
        public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
        {
            ScenePresence targetAvatar = null;
            ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
            ScenePresence parcelManager = null;
            ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
            System.Threading.Timer Timer;

            if (targetAvatar.UserLevel == 0)
            {
                ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
                if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
                    return;
                if (flags == 0)
                {
                    targetAvatar.AllowMovement = false;
                    targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds.  You cannot move or interact with the world.");
                    parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
                    System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
                    Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
                    Timers.Add(targetAvatar.UUID, Timer);
                }
                else
                {
                    targetAvatar.AllowMovement = true;
                    targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
                    parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
                    Timers.TryGetValue(targetAvatar.UUID, out Timer);
                    Timers.Remove(targetAvatar.UUID);
                    Timer.Dispose();
                }
            }
        }
Beispiel #53
0
        /// <summary>
        /// Write the Cache logs and the Error Cache log to the Regular log file.
        /// </summary>
        private void WriteRTFCacheLogs()
        {
            //  If the Output Setting is not the LoggerOutput.Regular.
            if (_OutputSetting != LoggerOutputSetting.RTF)
            {
                AddLog("The Output is not RTF, output have error.",
                    "Logger::WriteRTFCacheLogs()", LogType.Debug);
                return;
            }

            lock (lockthis)
            {
                AddLog("Lock the list and output the logs.",
                    "Logger::WriteRTFCacheLogs()", LogType.Debug);

                //  When the log cache have items
                if (_LogsCache.Count != 0)
                {
                    try
                    {
                        RichTextBox output = new RichTextBox();
                        output.Rtf = String.Empty;

                        if (File.Exists(_LogFilePath + "\\" + ConstLogFileName + ".rtf"))
                            output.LoadFile(_LogFilePath + "\\" + ConstLogFileName + ".rtf", RichTextBoxStreamType.RichText);

                        foreach (Log _log in _LogsCache)
                        {
                            output.Select(output.Text.Length, 0);
                            output.SelectedRtf = FormatLogRTF(_log) + "\r\n";
                        }

                        output.SaveFile(_LogFilePath + "\\" + ConstLogFileName + ".rtf", RichTextBoxStreamType.RichText);

                        //  Clear cache logs
                        _LogsCache.Clear();
                    }
                    catch (Exception e)
                    {
                        AddLog("The output got some error. Type: " + e.GetType() + ", Message: " + e.Message,
                            "Logger::WriteRTFCacheLogs()", LogType.Debug);

                        _OutputSetting = LoggerOutputSetting.NotWriteToFileRTF;
                        AddLog("Change the output setting to \"NotWriteToFileRTF\".", "Logger::WriteRTFCacheLogs()", LogType.Debug);

                        //  Close the Thread
                        if (timer != null)
                            timer.Dispose();
                        timerDelegate = null;

                        AddLog("Close the output Thread.", "Logger::WriteRTFCacheLogs()", LogType.Debug);

                        throw;
                    }
                }
            }
        }
Beispiel #54
0
 public TimerNotificationInfo(int notificationId, string type, string message, object userData, DateTime date, TimeSpan period, long nbOccurences, bool fixedRate, System.Threading.TimerCallback callback, CheckSendPastNotificationsDelegate sendPastNotifications)
 {
     _notificationId = notificationId;
     _type = type;
     _message = message;
     _userData = userData;
     _date = date;
     _period = period;
     _nbOccurences = nbOccurences;
     _fixedRate = fixedRate;
     _callback = callback;
     _sendPastNotifications = sendPastNotifications;
 }
 public void Start()
 {
     _startTimeStamp = DateTime.Now.Subtract(_duration);
     _timerCallback = new System.Threading.TimerCallback(TimerElapsed);
     _timer = new System.Threading.Timer(_timerCallback);
     _timer.Change(0, 1000);
 }
Beispiel #56
0
        /// <summary>
        /// Write the Cache logs and the Error Cache log to the Regular log file.
        /// </summary>
        private void WriteRegularCacheLogs()
        {
            //  If the Output Setting is not the LoggerOutput.Regular.
            if (_OutputSetting != LoggerOutputSetting.Regular)
            {
                AddLog("The Output is not Regular, output have error.",
                    "Logger::WriteRegularCacheLogs()", LogType.Debug);
                return;
            }

            lock (lockthis)
            {
                AddLog("Lock the list and output the logs.",
                    "Logger::WriteRegularCacheLogs()", LogType.Debug);

                //  When the log cache have items
                if (_LogsCache.Count != 0)
                {
                    try
                    {
                        //  Create a new StreamWriter class to save the logs.
                        StreamWriter writer = new StreamWriter(_LogFilePath + "\\" + ConstLogFileName + ".log", true);

                        foreach (Log _log in _LogsCache)
                            writer.WriteLine(FormatLogString(_log));
                        writer.Close();

                        //  Clear cache logs
                        _LogsCache.Clear();
                    }
                    catch (Exception e)
                    {
                        AddLog("The output got some error. Type: " + e.GetType() + ", Message: " + e.Message,
                            "Logger::WriteRegularCacheLogs()", LogType.Debug);

                        _OutputSetting = LoggerOutputSetting.NotWriteToFileRegular;
                        AddLog("Change the output setting to \"NotWriteToFileRegular\".", "Logger::WriteRegularCacheLogs()", LogType.Debug);

                        //  Close the Thread
                        if (timer != null)
                            timer.Dispose();
                        timerDelegate = null;
                        AddLog("Close the output Thread.", "Logger::WriteRegularCacheLogs()", LogType.Debug);

                        throw;
                    }
                }
            }
        }
 public void Run(WorkItem workProc,object o, int delay, int interval)
 {
     System.Threading.TimerCallback t = new System.Threading.TimerCallback(workProc);
     timer = new System.Threading.Timer(t, o, delay, interval); 
    
 }
 private void HoursAccounting_Shown(object sender, EventArgs e)
 {
     // Start keep-alive timer
     _keepAliveCallback = new System.Threading.TimerCallback(KeepSessionAlive);
     _keepAlive = new System.Threading.Timer(_keepAliveCallback);
     _keepAlive.Change(600000, 600000);
 }
Beispiel #59
0
 /// <summary>
 /// Start a thread for output.
 /// </summary>
 private void OutputThread()
 {
     //  Create a TimerCallback, it will run OutputCacheLogs(Object)
     this.timerDelegate = new System.Threading.TimerCallback(OutputCachedLogs);
     //  Create the Timer Class, to set the TimerCallback will run every ConstCacheTimeInterval millisecond.
     this.timer = new System.Threading.Timer(timerDelegate, null, ConstCacheTimeInterval, ConstCacheTimeInterval);
 }