コード例 #1
0
ファイル: Form1.cs プロジェクト: junas/RadarGraph
 public Form1()
 {
     InitializeComponent();
     _radarTimer = new Timer(10);
     _radarTimer.Elapsed += _radarTimer_Elapsed;
     _radarTimer.Start();
 }
コード例 #2
0
 public ToolTipHandler() {
     uiTimer = new Timer();
     uiTimer.Interval = 14;
     uiTimer.AutoReset = true;
     uiTimer.Elapsed += uiTimer_Tick;
     uiTimer.Start();
 }
コード例 #3
0
 public void Dispose() {
     Application.RemoveMessageFilter(this);
     if (uiTimer != null)
     {
         uiTimer.Stop();
         uiTimer = null;
     }
 }
コード例 #4
0
ファイル: Email.cs プロジェクト: varlo/Unona9
        public static void InitializeMailerTimer()
        {
            tMailer = new Timer();
            tMailer.AutoReset = true;
            tMailer.Interval = TimeSpan.FromDays(1).TotalMilliseconds;
            tMailer.Elapsed += new ElapsedEventHandler(tMailer_Elapsed);
            tMailer.Start();

            // Run payment processing the 1st time
            tMailer_Elapsed(null, null);
        }
コード例 #5
0
        public void ExampleTimerCanBeObservable()
        {
            var counter = 0;
            var timer   = new System.Timers.Timer(interval: 10)
            {
                Enabled = true
            };
            IObservable <EventPattern <ElapsedEventArgs> > ticks =
                Observable.FromEventPattern <ElapsedEventHandler, ElapsedEventArgs>(
                    handler => (s, a) => handler(s, a),
                    handler => timer.Elapsed += handler,
                    handler => timer.Elapsed -= handler
                    );

            ticks
            .Select(_ => counter++)
            .Subscribe(_ => Console.WriteLine($"Timer\t:{counter}"));
        }
コード例 #6
0
        public DodgeHelp(GlobalInputHook hk) : base(hk)
        {
            foreach (var key in _movementKeys)
            {
                hk.HookedKeys.Add(key);
                _keyStates[key.ToString()] = false;
            }

            hk.HookedKeys.Add(_dodgeButton);
            hk.HookedKeys.Add(Keys.Space);

            hk.KeyDown += HkOnKeyDown;
            hk.KeyUp   += HkOnKeyUp;

            var timer1 = new System.Timers.Timer(TimerDelay);

            timer1.Elapsed += Timer1OnElapsed;
            timer1.Start();
        }
コード例 #7
0
ファイル: ConnectManager.cs プロジェクト: stonezhu870/istock
        public void CreateOceanSocket()
        {
            SocketConnection skOcean = new SocketConnection(_dataQuery, TcpService.WPFW);

            skOcean.OnConnectServSuccess += skOcean_OnConnectServSuccess;
            skOcean.OnReceiveData        += skRealTime_OnReceiveData;
            skOcean.Connect();
            SocketConnections[TcpService.WPFW] = skOcean;
            ReqLogonDataPacket packet = new ReqLogonDataPacket();

            Request(packet);
            Request(_heartOcean);
            if (_timeOcean == null)
            {
                _timeOcean          = new System.Timers.Timer(60000);
                _timeOcean.Elapsed += _timerOcean_Elapsed;
                _timeOcean.Start();
            }
        }
コード例 #8
0
ファイル: ConnectManager.cs プロジェクト: stonezhu870/istock
        /// <summary>
        /// CreateRealTimeTcp
        /// </summary>
        public void CreateRealTimeTcp()
        {
            TcpConnection tcpRealTime = new TcpConnection();

            tcpRealTime.SerMode = ServerMode.RealTime;
            tcpRealTime.OnConnectServSuccess += tcpRealTime_OnConnectServSuccess;
            tcpRealTime.OnReceiveData        += tcpHistory_OnReceiveData;
            tcpRealTime.Connect(new IpAddressPort(IpServerRealTime, PortServerRealTime));
            TcpConnections.Add((short)ServerMode.RealTime, tcpRealTime);
            Request(_heartRealTime);
            if (_timerRealTime == null)
            {
                _timerRealTime           = new System.Timers.Timer(60000);
                _timerRealTime.Elapsed  += _timerRealTime_Elapsed;
                _timerRealTime.AutoReset = true;
                _timerRealTime.Enabled   = true;
                _timerRealTime.Start();
            }
        }
コード例 #9
0
        public MainWindow()
        {
            if (!this.IsSingleInstance())
            {
                MessageBox.Show("Aplikacja jest już uruchomiona");
                System.Windows.Application.Current.Shutdown();
            }
            InitializeComponent();

            _mouseMoveSteps = 7;
            _mouseMove      = 5;
            _mouseMoveHold  = 20;

            _receiveTimer          = new Timer(30);
            _receiveTimer.Elapsed += new ElapsedEventHandler(OnTimeEvent);

            NotifyConfig();
            RemoteConfig();
        }
コード例 #10
0
        public void Init()
        {
            {
                InputPlugins = new List <InputList>();
                List <InputList> tempList = new List <InputList>();
                foreach (var item in CoreSolids.InputPlugins)
                {
                    tempList.Add(new InputList
                    {
                        Id   = item.Id,
                        Name = item.Name
                    });
                }

                InputPlugins = tempList;
            }


            {
                OutputPlugins = new List <OutputList>();
                List <OutputList> tempList = new List <OutputList>();
                foreach (var item in CoreSolids.OutputPlugins)
                {
                    tempList.Add(new OutputList
                    {
                        Id   = item.Id,
                        Name = item.Name
                    });
                }

                OutputPlugins = tempList;
            }


            // Create a timer with a two second interval.
            Timer aTimer = new System.Timers.Timer(10);

            // Hook up the Elapsed event for the timer.
            aTimer.Elapsed  += OnTimedEvent;
            aTimer.AutoReset = true;
            aTimer.Enabled   = true;
        }
コード例 #11
0
ファイル: Cache.cs プロジェクト: Nucs/nlib
            public CountdownTimer(int interval, bool start = false)
            {
                _interval = interval;
                enabled   = interval > 0;
                t         = new Timer(interval <= 0 ? 1 : interval)
                {
                    AutoReset = false, Enabled = false
                };

                t.Elapsed += (sender, args) => {
                    Stop();
                    _wait_sem.Release(100);
                    Elapsed?.Invoke();
                };

                if (start)
                {
                    Start();
                }
            }
コード例 #12
0
        public void Sync()
        {
            string taskId = DateTime.Now.ToString("yyyyMMddHHmmssfff");

            logger.Polling.Info($"[{taskId}]Start Polling Task.");
            logger.Sdk.Info($"[{taskId}]Start Polling Task.");
            if (!this.IsComplete)
            {
                logger.Polling.Warn($"[{taskId}]The last task was not completed, and the task was given up.");
                return;
            }
            var testResult = fusionDirectorService.TestLinkFd();

            if (!testResult.Success)
            {
                OnPollingError($"[{taskId}]Can not connect the FusionDirector {this.FusionDirectorIp}, and the task was given up.");
                return;
            }
            // 清除完成的任务
            this.taskList.Clear();
            var syncEnclosureListTask = this.SyncEnclosureList(taskId);

            this.taskList.Add(syncEnclosureListTask);
            var syncServerListTask = this.SyncServerList(taskId);

            this.taskList.Add(syncServerListTask);

            if (this.pluginConfig.IsEnableAlert)
            {
                System.Timers.Timer timer = new System.Timers.Timer(1000);
                timer.Elapsed += (sender, e) =>
                {
                    if (this.IsComplete)
                    {
                        this.SyncAlarm();
                        timer.Stop();
                    }
                };
                timer.Start();
            }
        }
コード例 #13
0
        public void Init(bool autoStart, int timeInterval, bool enabled)
        {
            if (enabled)
            {
                _OnReportEngineState(_threadName, GenericServiceThread.EngineStatusList.Initializing);
            }
            else
            {
                _OnReportEngineState(_threadName, GenericServiceThread.EngineStatusList.Sleeping);
            }

            this.autoStart            = autoStart;
            this.enabled              = enabled;
            this.sleepInterval        = timeInterval;
            this.defaultSleepInterval = timeInterval;
            workThread          = new Timer();
            workThread          = new System.Timers.Timer();
            workThread.Interval = timeInterval * 1000;
            workThread.Elapsed += new System.Timers.ElapsedEventHandler(Go);
            workThread.Start();
        }
コード例 #14
0
        void ProcessMethod(int timeLength, int year)
        {
            int timespan = 20;                             // 20 毫秒
            int count    = timeLength * (1000 / timespan); // 20 秒

            Console.WriteLine("倒计时 " + count / (1000 / timespan) + " 秒;");

            string currentYear = DateTime.Now.Year.ToString();

            timer          = new Timer(timespan);
            timer.Elapsed += (sender, args) =>
            {
                DateTime now = DateTime.Now;
                if (now.Year != year)
                {
                    //SysTimePro.SetTimeByCmd("2008",now.Month.ToString(),now.Day.ToString());
                    string timeStr = year + now.ToString("-MM-dd HH:mm:ss");
                    SysTimePro.SetLocalTimeByStr(timeStr);
                }

                if (--count == 0)
                {
                    timer.Stop();
                    string timeStr = currentYear + now.ToString("-MM-dd HH:mm:ss");
                    SysTimePro.SetLocalTimeByStr(timeStr);
                    System.Environment.Exit(1);
                }
                else
                {
                    if (count % (1000 / timespan) == 0)
                    {
                        this.Invoke(new Action(() =>
                        {
                            lbLeftTime.Text = (count / (1000 / timespan)).ToString();
                        }));
                    }
                }
            };
            timer.Start();
        }
コード例 #15
0
 public virtual void StartListener()
 {
     try
     {
         this.eventLogger.AddMessage(Resources.ListenerStartingMessage, Resources.ListenerStarting);
         this.logDistributor.StopReceiving = false;
         if (this.queueTimer == null)
         {
             this.queueTimer          = new Timer();
             this.queueTimer.Elapsed += new ElapsedEventHandler(OnQueueTimedEvent);
         }
         this.queueTimer.Interval = this.QueueTimerInterval;
         this.queueTimer.Enabled  = true;
         this.eventLogger.AddMessage(Resources.ListenerStartCompleteMessage, string.Format(Resources.Culture, Resources.ListenerStartComplete, this.QueueTimerInterval));
     }
     catch (Exception e)
     {
         this.eventLogger.AddMessage(Resources.ListenerStartErrorMessage, Resources.ListenerStartError);
         this.eventLogger.AddMessage(Resources.Exception, e.Message);
         throw;
     }
 }
コード例 #16
0
        /// <summary>
        /// Constructor for the MainViewModel.
        /// Test if Docker is there and everything is setup in the right way.
        /// Initializing the timer for time measuring and initialize the the collections.
        /// </summary>
        /// <param name="mainWindowActions">The actions of the main window.</param>
        public MainViewModel(IMainWindowActions mainWindowActions)
        {
            Trace.Listeners.Add(new LocalTraceListener());

            this.mainWindowActions = mainWindowActions;
            Task.Factory.StartNew(async() =>
            {
                TestDockerRunning();
                await TestDockerImagesAsync();
            });
            resultImages     = new ObservableCollection <ResultImageViewModel>();
            progresStopwatch = new Stopwatch();

            Worker.Instance.ProcessEvent += ProcessEventHandlerAsync;

            progressTimer = new Timer(1000)
            {
                AutoReset = true
            };
            progressTimer.Elapsed += ProgressTimer_Elapsed;
            progressTimer.Enabled  = true;
        }
コード例 #17
0
        private void ShowStream(IMatchVw match)
        {
            if (FirstStart)
            {
                //https://lbc.betradar.com/screen/#/terminal/76/4900522/656
                StreamWebAddress     = "https://lbc.betradar.com/";
                WebBrowserVisibility = Visibility.Visible;
                FirstStart           = false;
                return;
            }

            //add timers logic
            SelectedMatch = match;

            if (DateTime.Now < SelectedMatch.LastPlayedStreamAt.AddSeconds(ChangeTracker.VideoWarningBefore))
            {
                ShowError(TranslationProvider.Translate(MultistringTags.TERMINAL_STREAM_BLOCKED).ToString());
                return;
            }

            SelectedMatch.LastPlayedStreamAt = DateTime.Now;

            WebBrowserVisibility = Visibility.Visible;

            StopTimer();

            bool res = DeleteUrlCacheEntry("https://lbc.betradar.com/screen/jwplayer.flash.swf");

            StreamWebAddress = "https://lbc.betradar.com/screen/#/terminal/76/" + SelectedMatch.LineObject.BtrMatchId.ToString() + "/" + SelectedMatch.StreamID.ToString();

            Random random       = new Random();
            int    randomNumber = (random.Next(ChangeTracker.VideoTimePeriodMin, ChangeTracker.VideoTimePeriodMax) - ChangeTracker.VideoWarningBefore) * 1000;

            StreamTimer          = new System.Timers.Timer();
            StreamTimer.Interval = randomNumber;
            StreamTimer.Elapsed += NotifyUserOfStreamEnding;
            StreamTimer.Start();
        }
コード例 #18
0
ファイル: ConnectManager.cs プロジェクト: stonezhu870/istock
        /// <summary>
        /// CreateOceanTcp
        /// </summary>
        public void CreateOceanTcp()
        {
            TcpConnection tcpOcean = new TcpConnection();

            tcpOcean.SerMode = ServerMode.Oversea;
            tcpOcean.OnConnectServSuccess += tcpOcean_OnConnectServSuccess;
            tcpOcean.OnReceiveData        += tcpHistory_OnReceiveData;
            tcpOcean.Connect(new IpAddressPort(IpServerOcean, PortServerOcean));
            TcpConnections.Add((short)ServerMode.Oversea, tcpOcean);

            ReqLogonDataPacket packet = new ReqLogonDataPacket();

            Request(packet);
            Request(_heartRealTime);
            if (_timerRealTime == null)
            {
                _timerRealTime           = new System.Timers.Timer(60000);
                _timerRealTime.Elapsed  += _timerRealTime_Elapsed;
                _timerRealTime.AutoReset = true;
                _timerRealTime.Enabled   = true;
                _timerRealTime.Start();
            }
        }
コード例 #19
0
        private void OddPlaced(decimal odd)
        {
            if (WebBrowserVisibility != Visibility.Visible)
            {
                return;
            }

            if (StreamTimer == null)
            {
                return;
            }

            Random random       = new Random();
            int    randomNumber = (random.Next(ChangeTracker.VideoTimePeriodMin, ChangeTracker.VideoTimePeriodMax) - ChangeTracker.VideoWarningBefore) * 1000 + (int)odd * 1000;

            StreamTimer.Elapsed -= NotifyUserOfStreamEnding;
            StreamTimer.Elapsed -= EndStream;

            StreamTimer          = new System.Timers.Timer();
            StreamTimer.Interval = randomNumber;
            StreamTimer.Elapsed += NotifyUserOfStreamEnding;
            StreamTimer.Start();
        }
コード例 #20
0
        // When the user clicks start looping it starts looping.
        private void LoopButton_Click(object sender, RoutedEventArgs e)
        {
            if (LoopButton.Content.Equals("Start Looping"))
            {
                LoopButton.Content = "Stop Looping";
                // First get the current display
                Display display = CurrentDisplayList.CurrentDisplay();

                // Set the view to that display
                SetDisplay(display);

                // Start the timer
                PageTimer          = new System.Timers.Timer(display.Timer * 1000);
                PageTimer.Elapsed += DisplayTimer_Elapsed;
                PageTimer.Start();
            }
            else
            {
                LoopButton.Content = "Start Looping";

                PageTimer.Stop();
            }
        }
コード例 #21
0
        public static async Task ForEachWithDelay <T>(this ICollection <T> items, Func <T, Task> action, double interval)
        {
            using (var timer = new System.Timers.Timer(interval))
            {
                var task      = new Task(() => { });
                int remaining = items.Count;
                var queue     = new ConcurrentQueue <T>(items);

                timer.Elapsed += async(sender, args) =>
                {
                    T item;
                    if (queue.TryDequeue(out item))
                    {
                        try
                        {
                            await action(item);
                        }
                        finally
                        {
                            // Complete task.
                            remaining -= 1;

                            if (remaining == 0)
                            {
                                // No more items to process. Complete task.
                                task.Start();
                            }
                        }
                    }
                };

                timer.Start();

                await task;
            }
        }
コード例 #22
0
        public static void ServerStart()
        {
            host = new ServiceHost(typeof(BookMyFoodWCF.ServiceChat));

            //restClient.Proxy = WebRequest.GetSystemWebProxy();
            //restClient.Proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

            try
            {
                host.Open();
                Console.WriteLine("Host is Started");
                LeaderServer.Leader.ServerState = ServerStates.DelivererSet;

                aTimer = new Timer(30000);
                // Hook up the Elapsed event for the timer.
                aTimer.Elapsed  += MonitoringStringAutoUpdating;
                aTimer.AutoReset = true;
                aTimer.Enabled   = true;
            }
            catch (AddressAlreadyInUseException e)
            {
                throw;
            }
        }
コード例 #23
0
 void DoRefillHopper()
 {
     BoLib.setUtilRequestBitState((int)UtilBits.RefillCoins);
     DenomVisibility = System.Windows.Visibility.Visible;
     if (_refillTimer == null)
     {
         CoinDenominationMsg = "0.20";
         RefillMessage = "Insert Coins. Press Stop to End Refill.";
         _refillTimer = new Timer() { Enabled = true, Interval = 200 };
         _refillTimer.Elapsed += (sender, e) =>
         {
             RefillCoinsAddedLeft = BoLib.getHopperFloatLevel((byte)Hoppers.Left);
             RefillCoinsAddedRight = BoLib.getHopperFloatLevel((byte)Hoppers.Right);
         };
         BoLib.getUtilRequestBitState((int)UtilBits.RefillCoins);
     }
     else if (!_refillTimer.Enabled)
     {
         CoinDenominationMsg = "1.00";
         RefillMessage = "Insert Coins. Press Stop to End Refill.";
         _refillTimer.Enabled = true;
         BoLib.getUtilRequestBitState((int)UtilBits.RefillCoins);
     }
 }
コード例 #24
0
ファイル: TreeView.cs プロジェクト: ChrisMoreton/Test3
		/// <summary>
		/// Starts the timer for the tooltip
		/// </summary>
		private void StartTooltipTimer()
		{
			// check for tooltips
			if (Tooltips == false)
				return;

			if (m_TooltipTimer != null)
			{
				m_TooltipTimer.Enabled = false;
				m_TooltipTimer.Dispose();
			}

			if (m_Tooltip != null)
			{
				m_Tooltip.Hide();
				m_Tooltip.DestroyHandle();
			}

			if (TooltipNode.TextTruncated == true)
				m_TooltipTimer = new System.Timers.Timer(600);
			else
				m_TooltipTimer = new System.Timers.Timer(800);

			m_TooltipTimer.Elapsed += new ElapsedEventHandler(this.OnTooltipTimer);
			m_TooltipTimer.Enabled = true;
		}
コード例 #25
0
ファイル: GrabJob.cs プロジェクト: Echilon/CsvGrabber
 public GrabJob()
 {
     Logger = new ConsoleLogger();
     tmr = new Timer();
     tmr.Elapsed += new System.Timers.ElapsedEventHandler(tmr_Elapsed);
 }
コード例 #26
0
ファイル: GameWorldModel.cs プロジェクト: jchunzh/ShoutyBird
 public void Simulate()
 {
     Status = GameStatus.Running;
     SetupGame();
     _gameWorldUpdateTimer = new Timer(TimerTick);
     _gameWorldUpdateTimer.Elapsed += Update;
     _gameWorldUpdateTimer.AutoReset = true;
     _gameWorldUpdateTimer.Start();
 }
コード例 #27
0
ファイル: MainWindow.xaml.cs プロジェクト: r0699140/Wireshell
        //Zal aan de hand van een query true of false geven als de gegeven data overeen komt met data in de databank
        //Als de login sucsesvol is zal CleanRows ook worden uitgevoerd
        internal bool LoginUser(string email, string password)
        {
            userID = 0;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    connection.Open();
                    MySqlCommand cmd = new MySqlCommand("sp_getUserMail", connection)
                    {
                        CommandType = System.Data.CommandType.StoredProcedure
                    };
                    cmd.Parameters.AddWithValue("mail", email);

                    using (MySqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            return(false);
                        }

                        reader.Read();
                        if (!BCrypt.Net.BCrypt.Verify(password, reader["PasswordHash"].ToString()))
                        {
                            return(false);
                        }

                        if (!reader.GetBoolean("Activated"))
                        {
                            userID = -1;
                            return(false);
                        }

                        userID = Int16.Parse(reader["AccountID"].ToString());

                        Settings.Default.UserLoggedOn = true;
                        Settings.Default.Email        = email;
                        Settings.Default.Password     = password;
                        Settings.Default.Name         = reader["Name"].ToString();
                        Settings.Default.Firstname    = reader["FirstName"].ToString();

                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            LogoutButton.Content = "Logout";
                            UserName.Text = Settings.Default.Firstname + " " + Settings.Default.Name;
                            AccountButton.Text = "ACCOUNT";
                        }));

                        Timer uploadTimer = new System.Timers.Timer(refreshTime * 7000);

                        uploadTimer.Elapsed  += UploadData;
                        uploadTimer.AutoReset = true;
                        uploadTimer.Enabled   = true;
                        loggedIn = true;

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(true);
            }
            finally
            {
                Settings.Default.Save();
            }
        }
コード例 #28
0
        private void txtFilterByName_TextChanged(object sender, EventArgs e)
        {
            if (mLazyLoadingFilteringTimer == null)
            {
                mLazyLoadingFilteringTimer =  new System.Timers.Timer(500);
                mLazyLoadingFilteringTimer.Elapsed +=
                    new System.Timers.ElapsedEventHandler(mLazyLoadingFilteringTimer_Elapsed);
            }

            if (txtFilterByName.Text != String.Empty && txtFilterByName.Text != "Filter By Name")
            {
                if (txtFilterByName.Text.Length > 2)
                {
                    mLazyLoadingFilteringTimer.Enabled = true;
                    mLazyLoadingFilteringTimer.Start();
                }
            }
            else
            {
                mLazyLoadingFilteringTimer.Enabled = false;
                BindingSource bs = new BindingSource();
                bs.DataSource = mCandidateManagment.GetAllCandidates();
                SetDataGridViewDataSource(dgv, bs);
            }
        }
コード例 #29
0
ファイル: MsmqListener.cs プロジェクト: bnantz/NCS-V1-1
        /// <summary>
        /// Start the queue listener and begin polling the message queue.
        /// </summary>
        public virtual void StartListener()
        {
            try
            {
                this.eventLogger.AddMessage(SR.ListenerStartingMessage, SR.ListenerStarting);

                this.logDistributor.StopReceiving = false;

                if (this.queueTimer == null)
                {
                    this.queueTimer = new Timer();
                    this.queueTimer.Elapsed += new ElapsedEventHandler(OnQueueTimedEvent);
                }
                this.queueTimer.Interval = this.QueueTimerInterval;
                this.queueTimer.Enabled = true;

                this.eventLogger.AddMessage(SR.ListenerStartCompleteMessage, SR.ListenerStartComplete(this.QueueTimerInterval));
            }
            catch (Exception e)
            {
                this.eventLogger.AddMessage(SR.ListenerStartErrorMessage, SR.ListenerStartError);
                this.eventLogger.AddMessage("exception", e.Message);
                throw;
            }
            catch
            {
                this.eventLogger.AddMessage(SR.ListenerStartErrorMessage, SR.ListenerStartError);
                this.eventLogger.AddMessage("exception", SR.UnknownError);
                throw;
            }
        }
コード例 #30
0
        public override void Init()
        {
            try
            {
                timer1 = new System.Timers.Timer();
                timer1.Elapsed += timer1_Tick;
                timer1.Interval = timer_interval;
                timer1.AutoReset = false;
                timer1.Enabled = true;

                if (usingRegistry)
                {
                    if (!reg_flag)
                    {
                        if (!Read_Registry())
                        {
                            L.Log(LogType.FILE, LogLevel.ERROR, "Error on Reading the Registry ");
                            return;
                        }
                        if (!Initialize_Logger())
                        {
                            L.Log(LogType.FILE, LogLevel.ERROR, "Error on Intialize Logger on EventLogFileAuditRecorder functions may not be running");
                            return;
                        }
                        reg_flag = true;
                    }
                }
                else
                {
                    if (!reg_flag)
                    {
                        if (!Get_logDir())
                        {
                            L.Log(LogType.FILE, LogLevel.ERROR, "Error on Reading the Registry ");
                            return;
                        }
                        else
                            if (!Initialize_Logger())
                            {
                                L.Log(LogType.FILE, LogLevel.ERROR, "Error on Intialize Logger on EventLogFileAuditRecorder Recorder  functions may not be running");
                                return;
                            }
                        L.Log(LogType.FILE, LogLevel.INFORM, "Start creating EventLogFileAuditRecorder DAL");
                        reg_flag = true;
                    }
                }
            }
            catch (Exception exception)
            {
                EventLog.WriteEntry("Security Manager EventLogFileAuditRecorder Recorder Init", exception.ToString(), EventLogEntryType.Error);
            }
            L.Log(LogType.FILE, LogLevel.DEBUG, "  EventLogFileAuditRecorder Init Method end.");
        }
コード例 #31
0
 public EventLogFileAuditRecorder()
 {
     _handles2["00000"] = new AuditLogonEnv2("00000");
     _handles2["00000"].ProcessLastAudit["-----"] = new AuditHandle2("12313", "-----", "test");
     cleanupTimer = new Timer { AutoReset = false, Interval = 60000 };
     cleanupTimer.Elapsed += new ElapsedEventHandler(cleanupTimer_Elapsed);
     cleanupTimer.Start();
     enc = Encoding.UTF8;
 }
コード例 #32
0
 private SDIntegration()
 {
     loadingProjectTimer           = new Timer(LoadingProjectTimeout);
     loadingProjectTimer.AutoReset = false;
     loadingProjectTimer.Elapsed  += new System.Timers.ElapsedEventHandler(loadingProjectTimer_Elapsed);
 }
コード例 #33
0
ファイル: Application.cs プロジェクト: oliversalzburg/omniudp
        /// <summary>
        ///     Create UID reader context and wait for events.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        ///     There are currently no readers installed.
        /// </exception>
        protected virtual void ExecuteContext()
        {
            try {
                // Retrieve the names of all installed readers.
                using( Context = new SCardContext() ) {
                    Context.Establish( SCardScope.System );

                    string[] readernames = null;
                    try {
                        Log.Info( "Attempting to retrieve connected readers..." );
                        readernames = Context.GetReaders();
                    } catch( PCSCException ) {}

                    SCardMonitor monitor = null;

                    if( null == readernames || 0 == readernames.Length ) {
                        //throw new InvalidOperationException( "There are currently no readers installed." );
                        Log.Warn( "There are currently no readers installed. Re-attempting in 10 seconds." );

                        if( null == RetryTimer ) {
                            RetryTimer = new Timer( TimeSpan.FromSeconds( 10 ).TotalMilliseconds );
                            RetryTimer.Elapsed += ( e, args ) => { ExecuteContext(); };
                            RetryTimer.Start();
                        }
                    } else {
                        if( null != RetryTimer ) {
                            RetryTimer.Stop();
                            RetryTimer.Dispose();
                        }

                        // Create a monitor object with its own PC/SC context.
                        monitor = new SCardMonitor( new SCardContext(), SCardScope.System );

                        // Point the callback function(s) to the static defined methods below.
                        monitor.CardInserted += CardInserted;

                        foreach( string reader in readernames ) {
                            Log.InfoFormat( "Start monitoring for reader '{0}'.", reader );
                        }

                        monitor.Start( readernames );
                    }

                    // Wait for the parent application to signal us to exit.
                    if( null == ExitApplication ) {
                        ExitApplication = new ManualResetEvent( false );
                    }
                    ExitApplication.WaitOne();

                    // Stop monitoring
                    if( null != monitor ) {
                        monitor.Cancel();
                        monitor.Dispose();
                        monitor = null;
                    }
                }
            } catch( PCSCException pcscException ) {
                Log.Error( "Failed to run application", pcscException );
            }
        }
コード例 #34
0
        static void Main(string[] args)
        {
            var proceed = false;
            var threads = 1;
            var timer = 1;
            LoadTime = new Timer {Interval = 1000};

            while (!proceed)
            {
                Console.WriteLine("INPUT: # of threads/Interval");
                if (!int.TryParse(Console.ReadLine(), out threads))
                {
                    Console.WriteLine("Not a number/Int");
                }
                else proceed = true;
            }
            proceed = false;
            while (!proceed)
            {
                Console.WriteLine("INPUT: timer span in seconds");
                if (!int.TryParse(Console.ReadLine(), out timer))
                {
                    Console.WriteLine("Not a number/Int");
                }
                else
                {
                    proceed = true;
                    timer *= 1000;
                }
            }

            var runners = new Thread[threads];
            LoadTime.Elapsed += new ElapsedEventHandler(delegate { TimeElapsed(new object(), new EventArgs(), timer, runners); });
            //del = new;
            //var call = new Caller(5);
            //var thing = new Del();

            LoadTime.Enabled = true;

            for (var i = 0; i < threads; i++)
            {
                runners[i] = new Thread(a => Call(timer, i));
                runners[i].Start();
            }

            Console.ReadKey();
        }
コード例 #35
0
 private ScheduleUtil()
 {
     timer          = new System.Timers.Timer(14);
     timer.Elapsed += callback;
     timer.Start();
 }
コード例 #36
0
        public void Init(bool autoStart, int timeInterval,bool enabled)
        {
            if(enabled)
                _OnReportEngineState(_threadName, GenericServiceThread.EngineStatusList.Initializing);
            else
                _OnReportEngineState(_threadName, GenericServiceThread.EngineStatusList.Sleeping);

            this.autoStart = autoStart;
            this.enabled = enabled;
            this.sleepInterval = timeInterval;
            this.defaultSleepInterval = timeInterval;
            workThread=new Timer();
            workThread = new System.Timers.Timer();
            workThread.Interval = timeInterval*1000;
            workThread.Elapsed+=new System.Timers.ElapsedEventHandler(Go);
            workThread.Start();
        }
コード例 #37
0
 public override void SetConfigData(Int32 Identity, String Location, String LastLine, String LastPosition,
  String LastFile, String LastKeywords, bool FromEndOnLoss, Int32 MaxLineToWait, String User,
  String Password, String RemoteHost, Int32 SleepTime, Int32 TraceLevel,
  String CustomVar1, int CustomVar2, String Virtualhost, String dal, Int32 Zone)
 {
     usingRegistry = false;
     Id = Identity;
     location = Location;
     fromend = FromEndOnLoss;
     timer_interval = SleepTime; //Timer interval.
     trc_level = TraceLevel;
     virtualhost = Virtualhost;
     last_recordnum = Convert_To_Int64(LastPosition); //Last position
     Dal = dal;
     lastFile = LastFile;
     user = User;
     password = Password;
     remoteHost = RemoteHost;
     Exception error = null;
     ConfigHelper.ParseKeywords(CustomVar1, OnKeywordParsed, null, null, ref error);
     triggerTimer = new Timer { AutoReset = false, Interval = 10 };
     triggerTimer.Elapsed += new ElapsedEventHandler(triggerTimer_Elapsed);
     triggerTimer.Enabled = false;
 }
コード例 #38
0
        //
        //This is where the sentry will be activated to alert the user.
        //
        private static Tuple <int[], ArrayList, ArrayList> SentryModeActivate(int dataFrequency, string sensorType, double[] minimumAndMaximum, double secondsOfOperation, Finch myFinch)
        {
            ArrayList leftArray    = new ArrayList();
            ArrayList rightArray   = new ArrayList();
            int       countStepped = 0;
            double    holdRight;
            double    holdLeft;
            double    temperatureHold;
            double    temperatureF;

            int[] alertTrippedIndex = new int[(int)(secondsOfOperation)];
            Timer r = new System.Timers.Timer(secondsOfOperation * 1000);

            r.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            r.Enabled  = true;
            bool running = true;
            int  i       = 0;

            //
            //This system will gather when alerts go off.
            //
            while (running)
            {
                int a = 0;
                i++;
                Console.WriteLine($"Test {i}");
                Thread.Sleep(dataFrequency * 1000);
                if (sensorType == "light")
                {
                    //
                    //When Light is selected we will get the light data from the left and right sensors and within the light range
                    //
                    holdLeft  = myFinch.getLeftLightSensor();
                    holdRight = myFinch.getRightLightSensor();
                    if (holdLeft < minimumAndMaximum[0] && holdRight <minimumAndMaximum[0] && holdLeft> minimumAndMaximum[1] && holdRight > minimumAndMaximum[1])
                    {
                        countStepped = i;
                        leftArray.Add(holdLeft);
                        rightArray.Add(holdRight);
                        alertTrippedIndex[a] = countStepped;

                        Console.WriteLine("ALERT!");
                    }
                }
                //
                //When temperature is selected we will get the temperature data in both F and C
                //
                if (sensorType == "temperature")
                {
                    temperatureHold = myFinch.getTemperature();
                    if (temperatureHold < minimumAndMaximum[0] && temperatureHold < minimumAndMaximum[1])
                    {
                        countStepped = i;
                        temperatureF = (temperatureHold * 9 / 5) + 32;

                        leftArray.Add(temperatureF);
                        rightArray.Add(temperatureHold);
                        alertTrippedIndex[a] = countStepped;
                        a++;
                        Console.WriteLine("ALERT!");
                    }
                }
            }
            r.Enabled = false;
            //
            //The timer off switch.
            //
            void timer_Elapsed(object sender, ElapsedEventArgs e)
            {
                running = false;
            }

            Tuple <int[], ArrayList, ArrayList> sentryResults = new Tuple <int[], ArrayList, ArrayList>(alertTrippedIndex, leftArray, rightArray);

            return(sentryResults);
        }
コード例 #39
0
ファイル: MsmqListener.cs プロジェクト: ChiangHanLung/PIC_VDS
		/// <summary>
		/// Start the queue listener and begin polling the message queue.
		/// </summary>
		public virtual void StartListener()
		{
			try
			{
				this.eventLogger.AddMessage(Resources.ListenerStartingMessage, Resources.ListenerStarting);

				this.logDistributor.StopReceiving = false;

				if (this.queueTimer == null)
				{
					this.queueTimer = new Timer();
					this.queueTimer.Elapsed += new ElapsedEventHandler(OnQueueTimedEvent);
				}
				this.queueTimer.Interval = this.QueueTimerInterval;
				this.queueTimer.Enabled = true;

				this.eventLogger.AddMessage(Resources.ListenerStartCompleteMessage, string.Format(Resources.Culture, Resources.ListenerStartComplete, this.QueueTimerInterval));
			}
			catch (Exception e)
			{
				this.eventLogger.AddMessage(Resources.ListenerStartErrorMessage, Resources.ListenerStartError);
				this.eventLogger.AddMessage(Resources.Exception, e.Message);
				throw;
			}
		}
コード例 #40
0
ファイル: Program.cs プロジェクト: MrJaeqx/TSE6-DP
        static void Main(string[] args)
        {
            Console.WriteLine("1: First-Come First-Serve");
            Console.WriteLine("2: Shortest Seek Time First");
            Console.WriteLine("3: SCAN");
            bool validChoice = false;
            int  choice;

            do
            {
                Console.WriteLine("Choose scheduling strategy (1 to 3): ");
                string consoleInput = Console.ReadLine();
                Int32.TryParse(consoleInput, out choice);
                if (choice >= 1 && choice <= 3)
                {
                    validChoice = true;
                }
                else
                {
                    Console.WriteLine("Doe dat ff niet");
                }
            } while (!validChoice);


            IDiskScheduling strategy;

            switch (choice)
            {
            case 1:
                strategy = new FCFSScheduling();
                break;

            case 2:
                strategy = new SSTFScheduling();
                break;

            case 3:
                strategy = new SCANScheduling();
                break;

            default:
                strategy = new FCFSScheduling();
                break;
            }

            Console.WriteLine("Using: ");
            foreach (int request in requests)
            {
                Console.Write(request + " ");
            }
            Console.WriteLine();

            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Interval = 500;
            timer.Elapsed += delegate
            {
                ScheduleRead(strategy, timer);
            };

            timer.Start();

            while (requests.Count != 0)
            {
                Thread.Sleep(0);
            }
            Console.ReadKey();
        }