示例#1
1
 private static void GetRealDataTimer(object source,ElapsedEventArgs e)
 {
     try
     {
         OdbcDataAdapter adapter = new OdbcDataAdapter("select A_CV from FIX", RealConnection);
         DataSet ds = new DataSet();
         adapter.Fill(ds, "FIX");
         
         for (int i = 0; i < 100; i++)
         {
             data[i] = ds.Tables[0].Rows[i]["A_CV"].ToString();
         }
         adapter.Dispose();
         // RealConnection..Close();
         
     }
     catch (Exception ex)
     {
         for (int i = 0; i < 100; i++)
         {
             data[i] = "???";
         }
         
     }
 }
示例#2
0
    public void pushWords(object sender, ElapsedEventArgs e)
    {
        if (queue == "") {
            queue = getPhrases ();
         }
        //get the last char of the queue, push to the UI
        string lastChar = queue.Substring(queue.Length - 1, 1);
        //Debug.Log ("queue: " + queue + ", lastChar: " + lastChar);

        //if the queue is empty(i.e. queue = "")
        //then get a new phrases and add to the queue
        if (queue.Length == 1) {
            phrasesToPush = " " + lastChar + phrasesToPush;
        } else {
            phrasesToPush = lastChar + phrasesToPush;
        }

        int textChar = phrasesToPush.Length;
        if (textChar > textLimit) {
            phrasesToPush = phrasesToPush.Remove(textLimit-1);
        }

        //remove it from the queue
        queue = queue.Remove (queue.Length - 1);

        /* old method */
        //string phrases_cur = getPhrases();
        //phrasesToPush = phrases_cur + " " + phrasesBefore;
    }
 private void CheckStatusForRegistered(Object sender, ElapsedEventArgs e)
 {
     lock (_lock)
     {
         foreach (AsyncRequestState clientState in _clientStateList)
         {
             if (clientState.CurrentContext.Session != null)
             {
                 ImageServiceClientManager manager = (ImageServiceClientManager)clientState.CurrentContext.Session["Manager"];
                 bool? status = manager.Status();
                 if (status.HasValue && status.Value == false)
                 {
                     clientState.CurrentContext.Response.Write(serializer.Serialize(new { isError = false, needToUpdate = true }));
                     clientState.CompleteRequest();
                 }
                 else if (!status.HasValue)
                 {
                     string errorMessage_ = manager.Notifier.GetLastError();
                     clientState.CurrentContext.Response.Write(serializer.Serialize(new { isError = true, errorMessage = errorMessage_ }));
                     clientState.CompleteRequest();
                     _clientStateList.Clear();
                     break;
                 }
             }
         }
     }
 }
 /// <summary>
 /// Laddar om prenumerationer när tiden gått ut.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void timerElapsed(object sender, ElapsedEventArgs e)
 {
     timer.Enabled = false;
     LaddaOmPrenumerationerTimer();
     Console.WriteLine("Det gick bra");
     timer.Enabled = true;
 }
示例#5
0
 // Specify what you want to happen when the Elapsed event is raised. 
 private static void OnTimerTick(object source, ElapsedEventArgs e)
 {
     Console.WriteLine(
         "{0} was called at {1} by the Elapsed event.",
         System.Reflection.MethodBase.GetCurrentMethod().Name,
         e.SignalTime.ToString("HH:mm:ss"));
 }
示例#6
0
 //Displays the current time each second
 public static void DisplayTimeEvent( object source, ElapsedEventArgs e )
 {
     //Writes time to console each second
     Console.Write("\r{0}", DateTime.Now.ToString("O"));
     timeTimer.Interval = GetSecondInterval();
     timeTimer.Start();
 }
 /// <summary>
 /// Resets the score label to its default look after the timer is expired.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The arguments belonging to the event</param>
 private void ResetScoreVisibility(object sender, ElapsedEventArgs e)
 {
     if (sender.GetType() == typeof(System.Timers.Timer))
     {
         ((System.Timers.Timer)sender).Dispose();
     }
     StateManager.Instance.NewMoneyPowerup = false;
 }
 void timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (this.countTicks < this.ticks)
     {
         this.countTicks++;
         this.Method();
     }
 }
    static void executeTimer(object sender, ElapsedEventArgs elapsedEventArgs)
    {
        IConnectionManager connectionManager = AspNetHost.DependencyResolver.Resolve<IConnectionManager>();
        IConnection connection = connectionManager.GetConnection<MyConnection>();

        connection.Broadcast(counter.ToString());
        counter += 1;
    }
示例#10
0
 private void HeartBeatRElapsed(object sender, ElapsedEventArgs e)
 {
     Debug.Log("RBEAT");
     AudioSource.PlayClipAtPoint(HeartBeats[1],player.transform.position);
     heartBeatR.Interval = HeartRate;
     heartBeatR.Enabled = false;
     heartBeatL.Enabled = true;
 }
示例#11
0
 private void ATimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
 {
     if (counter <= this.Ticks)
     {
        counter++;
        this.MethodTobeCalled();
     }
 }
示例#12
0
	void HandleElapsed1 (object sender, ElapsedEventArgs e)
	{
		Time--;
		if (Time == 0) 
		{
			GameOverStep1();
		}
	}
示例#13
0
	void cjdnsPoller_Elapsed(object sender, ElapsedEventArgs e)
	{
		cjdns.Refresh();
		if(cjdns.HasExited) {
			// Die sadly
			Environment.Exit(1);
		}
	}
示例#14
0
 private void refreshTimerHandler(object sender, ElapsedEventArgs e)
 {
     updateHostList = true;
     dots += ".";
     if (dots.Equals("......"))
     {
         dots = "";
     }
 }
示例#15
0
	static void ShowStackTrace (object o, ElapsedEventArgs e)
	{
		Console.WriteLine (counter);
		Console.WriteLine ("Threads Equal:   {0}", System.Threading.Thread.CurrentThread == startup_thread);
		if (counter++ > 5) {
			t.AutoReset = false;
			t.Enabled = false;
		}
	}
示例#16
0
        private void runMethodAfterTimeEvent(object source, ElapsedEventArgs e)
        {
            this.Stop();
            this.Enabled = false;

            this.Elapsed -= new ElapsedEventHandler(runMethodAfterTimeEvent);

            Debug.Log("The Elapsed event was raised at " + e.SignalTime);
            methodTrigger(this);
        }
示例#17
0
    public static void WriteTestLog( object source, ElapsedEventArgs e)
    {
        using (System.IO.StreamWriter file = new System.IO.StreamWriter("log.txt", true))
        {

            file.WriteLine(DateTime.Now.ToString("O"));
            logTimer.Interval = GetMinuteInterval();
            logTimer.Start();
        }
    }
        void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            timer.Stop();
            RibbonMenuItem item = selectedItem;
            if (item != null)
            {

                MyFunc d = delegate() { item.IsSubmenuOpen = true; };
                this.Dispatcher.BeginInvoke(d);
            }
        }
示例#19
0
 //Check for pending agent jobs
 static void scheduleTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     AgentDb db = new AgentDb();
     List<Job> jobs = db.CheckSchedule();
     if (jobs.Count > 0)
     {
         Agent agentInstance = new Agent(jobs);
         Thread t = new Thread(agentInstance.RunJobsAsync);
         t.Start();
     }
 }
示例#20
0
 public void Tick(object source, ElapsedEventArgs e)
 {
     //here we change picture to dowel or screw, then we fix it in to the wall like one position
     Mount mnt = Storage.passed [Storage.GetCounter ()];
     if(mnt.is_doweled)
         if(mnt.show_dowel)
             imgFixPreview.Pixbuf = new Gdk.Pixbuf(Storage.GetStreamFromResource(mnt.img_name));
         else
             imgFixPreview.Pixbuf = new Gdk.Pixbuf(Storage.GetStreamFromResource((mnt as Screw).dwl.img_name));
     Storage.passed [Storage.GetCounter ()].show_dowel = !Storage.passed [Storage.GetCounter ()].show_dowel;
 }
    // Elapsed event is raised if the Enabled property is true and the time interval (in milliseconds) defined by the Interval property elapses.
    void OnTimedEvent(object soruce, ElapsedEventArgs e)
    {
        lock (node)
        {
            if (trafficIntensity < initTrafficIntensity)
                trafficIntensity++;

            if (trafficIntensity < InitialTrafficIntensity)
            {
                myTimer.Interval = randNumber.Next(MIN_TIME, MAX_TIME);
                myTimer.Start();
            }
        }
    }
示例#22
0
文件: test.cs 项目: mono/gert
	static void Timer_Elapsed (object sender, ElapsedEventArgs e)
	{
		try {
			for (int i = 0; i < t.Count; i++) {
				Timer tmp = (Timer) t [i];
				lock (t_sync [i]) {
					tmp.Stop ();
					tmp.Start ();
				}
			}
		} catch (Exception ex) {
			Console.WriteLine ("Exception! " + ex.Message);
		}
	}
示例#23
0
 void HandleElapsed(object sender, ElapsedEventArgs e)
 {
     if (recent_notification) {
         notifications.Interval = 5000;
         recent_notification = false;
     }
     if (!recent_notification && webView.SearchText ("Reminders", true, true, true)) {
         Notification notify = new Notification ("Outlook Notification", "");
         notify.Urgency = Urgency.Normal;
         notify.Show ();
         recent_notification = true;
         notifications.Interval = 30000;
     }
 }
示例#24
0
    private void ClientBatchPOST(object sender, ElapsedEventArgs e)
    {
        JSONData packet = new JSONData("SamplePacket:" + mDuration);
        ClientSocket.Instance.POST(packet);

        Timer timer = (Timer)sender;

        mDuration += (int)timer.Interval;

        if (mDuration > 1000)
        {
            timer.Stop();
            Debug.Log("Completed TestStartPOST");
        }
    }
示例#25
0
    private void BubbleTimer_Elapsed(object sender, ElapsedEventArgs e)
    {
        bubbleShow = false;

        if (sender is Timer)
        {
            Timer timer = sender as Timer;
            timer.Stop();

            GUIContent content = timerMap[timer];
            Messenger<GUIContent>.Broadcast(Messages.BUBBLE_REMOVE, content);

            timerMap.Remove(timer);
        }
    }
示例#26
0
文件: server.cs 项目: mono/gert
	public void OnAcceptContinue (object sender, ElapsedEventArgs e)
	{
		Byte [] data = new Byte [3];
		data [0] = 1;
		data [1] = 5;
		data [2] = 7;
		try {
			_pendingClient.Send (data, data.Length, SocketFlags.None);
		} catch (SocketException) {
			// socket will be closed by the client
		} finally {
			_pendingClient = null;
		}

		_listener.BeginAccept (new AsyncCallback (OnAccept), _listener);
	}
    public void theout(object source, ElapsedEventArgs e)
    {
        string cmdId = GetCmdId();

        //如果没有未分配的任务,只计算路权
        if (cmdId == "0")
        {
            SetRoadRight();
            //UpdateCmd();
            return;
        }

        Route r = new Route();
        r.CalcRoute(cmdId);
        SetRoadRight();
        //UpdateCmd();

    }
示例#28
0
    private static void OnTimedEvent(object source, ElapsedEventArgs e)
    {
        int _code=0;
           //_code= checkrequests();

           // timervalues reqval = new timervalues();

           Decimal _no_requestcode = 0;
           int _no_code = 0;

           string myConnection = ConfigurationManager.ConnectionStrings["betConnectionString"].ConnectionString;
           SqlConnection conn = new SqlConnection(myConnection);

           try
           {
           conn.Open();
           SqlCommand cmd2 = new SqlCommand("SELECT count(request_code)AS Number FROM reqpayment WHERE (status='Incomplete')", conn);
           SqlDataReader reader = cmd2.ExecuteReader();
           while (reader.Read())
           {
               _no_requestcode = Convert.ToDecimal(reader["Number"].ToString());
           }
           if (_no_requestcode != 0)
           {

               _no_code = Convert.ToInt32(_no_requestcode);
           }
           conn.Close();
           }
           catch (Exception ex)
           {
           String error = ex.Message;
           }

           finally
           {
           conn.Close();
           }
          // _intvalue = _no_code;
           //return _no_code;

        //Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime);
           //return _code;
    }
示例#29
0
文件: test.cs 项目: mono/gert
	static void Timer_Expire (object sender, ElapsedEventArgs e)
	{
		try {
			for (int i = 0; i < t.Count; i++) {
				Timer tmp = (Timer) t [i];
				if (tmp.Equals (sender)) {
					if (oneShot) {
						lock (t_sync [i]) {
							tmp.Stop ();
							tmp.Start ();
						}
					}
					break;
				}
			}
		} catch (Exception ex) {
			Console.WriteLine ("Exception! " + ex.Message);
		}
	}
    // Elapsed event is raised if the Enabled property is true and the time interval (in milliseconds) defined by the Interval property elapses.
    void OnTimedEvent(object soruce, ElapsedEventArgs e)
    {
        float initWeight, trafficIntensity, red, green;
        foreach (Node n in grid.RoadSet)
        {
            lock (n)
            {
                initWeight = n.trafficTimer.InitialTrafficIntensity;
                trafficIntensity = Mathf.Clamp(n.trafficTimer.TrafficIntensity, 0, initWeight);
            }

            red = (initWeight - trafficIntensity) / initWeight;
            green = trafficIntensity / initWeight;

            if(trafficIntensity == 0)
                textureColor[n.gridX + n.gridY * width] = Color.blue;
            else
                textureColor[n.gridX + n.gridY * width] = Color.red * red + Color.green * green;
                
        }
        isUpdated = true;
    }
示例#31
0
 private void staticInfoTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     ProcessStaticInfo();
 }
示例#32
0
 private static void CreateServiceRequestTimerElapsed(object source, ElapsedEventArgs e)
 {
     CreateWorkItemsFromTemplate(templateServiceRequest);
 }
示例#33
0
 void sharedMemoryRetryTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     ConnectToSharedMemory();
 }
示例#34
0
        private static void WorkItemQueryUpdate(object source, ElapsedEventArgs e)
        {
            try
            {
                DateTime dtDoWorkStart = DateTime.Now;

                //Total time to complete is intDoWorkPause * 14
                // 4 pauses - in between each work item do work job
                // Each do work job has 2 * intDoWorkPauses as Thread.Sleeps inside of them

                Console.WriteLine("Doing Incident Work");
                DoSomeIncidentWork();

                //Wait for a bit before you do something else
                if (bSimulateHumanWaitTime)
                {
                    Thread.Sleep(intDoWorkPause);
                }

                Console.WriteLine("Doing Change Request Work");
                DoSomeChangeRequestWork();

                //Wait for a bit before you do something else
                if (bSimulateHumanWaitTime)
                {
                    Thread.Sleep(intDoWorkPause);
                }

                Console.WriteLine("Doing Service Request Work");
                DoSomeServiceRequestWork();

                //Wait for a bit before you do something else
                if (bSimulateHumanWaitTime)
                {
                    Thread.Sleep(intDoWorkPause);
                }

                Console.WriteLine("Doing Problem Work");
                DoSomeProblemWork();

                //Wait for a bit before you do something else
                if (bSimulateHumanWaitTime)
                {
                    Thread.Sleep(intDoWorkPause);
                }

                Console.WriteLine("Doing Some More Incident Work");
                DoSomeIncidentWork();

                DateTime dtDoWorkEnd = DateTime.Now;
                TimeSpan tsDoWork    = dtDoWorkEnd - dtDoWorkStart;
                pcDoWork.RawValue = (long)tsDoWork.TotalSeconds;
                Console.WriteLine("Do work completed (seconds): " + tsDoWork.TotalSeconds);
                Console.WriteLine("Do work interval (seconds): " + intRateOfWorkItemQueryAndUpdates / 1000);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.InnerException.Message);
            }
        }
示例#35
0
 private static void CreateReleaseTimerElapsed(object source, ElapsedEventArgs e)
 {
     CreateWorkItemsFromTemplate(templateRelease);
 }
示例#36
0
 private void DepositTimerOnElapsed(object sender, ElapsedEventArgs e)
 => _ethJsonRpcClientProxy?.eth_getBlockByNumber(BlockParameterModel.Latest)
 .ContinueWith(async t =>
示例#37
0
        void CheckCallbacks(object sender, ElapsedEventArgs e)
        {
            if (currentlyChecking)
            {
                return;
            }

            lock (checkLock)
            {
                if (currentlyChecking)
                {
                    return;
                }

                try
                {
                    currentlyChecking = true;

                    var dueTimeouts = GetDueTimeouts();
                    if (!dueTimeouts.Any())
                    {
                        return;
                    }

                    log.Info("Got {0} dues timeouts - will send them now", dueTimeouts.Count);
                    foreach (var timeout in dueTimeouts)
                    {
                        log.Info("Timeout!: {0} -> {1}", timeout.CorrelationId, timeout.ReplyTo);

                        var reply = new TimeoutReply
                        {
                            SagaId        = timeout.SagaId,
                            CorrelationId = timeout.CorrelationId,
                            DueTime       = timeout.TimeToReturn,
                            CustomData    = timeout.CustomData,
                        };

                        SendReply(timeout, reply);

                        MarkAsProcessed(timeout);
                    }

                    lastSuccess = DateTime.UtcNow;
                }
                catch (Exception exception)
                {
                    var timeSinceLastSuccess = DateTime.UtcNow - lastSuccess;

                    if (timeSinceLastSuccess > MaxAcceptedFailureTimeBeforeLogLevelEscalation)
                    {
                        log.Error(exception, "An error occurred while attempting to retrieve due timeouts and send timeout replies! The situation has been going on for {0}", timeSinceLastSuccess);
                    }
                    else
                    {
                        log.Warn(
                            "An error occurred while attempting to retrieve due timeouts and send timeout replies: {0} - if the situation persists for more than {1}, the log level will escalate from WARN to ERROR",
                            exception, MaxAcceptedFailureTimeBeforeLogLevelEscalation);
                    }
                }
                finally
                {
                    currentlyChecking = false;
                }
            }
        }
示例#38
0
        private  void TimeEvent( object source, ElapsedEventArgs e )
        {

        }
示例#39
0
 private static void OnTimedEvent(object source, ElapsedEventArgs e)
 {
     userTime--;
     time = userTime / 60 + ":" + ((userTime % 60) >= 10 ? (userTime % 60).ToString() : "0" + (userTime % 60));
 }
示例#40
0
        // Specify what you want to happen when the Elapsed event is raised.
        private static void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            //var list = db.Objets.ToList();
            //foreach (var item in list)
            //{
            //    if (!item.notifie && item.Statut == Enchere.Models.enumStatutObjet.EV && ((item.objetDateInsc.AddDays(item.objetDureeVente).Ticks - DateTime.Now.Ticks) / 10000) <= 86400000)
            //    {
            //        if (!db.Encherees.Where(a => a.objet.Id == item.Id).Any())
            //        {
            //            item.notifie = true;
            //            System.Diagnostics.Debug.WriteLine(" Sending Message Regarding Article: " + item.objetNom);
            //            string subject = item.objetNom + " expirera bientot";
            //            string body = "l'objet" + item.objetNom + " expirera bientot et il n'y a eu aucune enchère à date. Pensez à offrir un meilleur prix";
            //            System.Diagnostics.Debug.WriteLine("Time: " + System.DateTime.Now.ToLongTimeString());
            //            Controllers.AccountController.EnvoiMessage(item.User.Email, body, subject);
            //            return;
            //        }

            //    }

            //}

            var userList = db.Users.ToList();

            foreach (var item in userList)
            {
                if (item.dernierEnvoiRapport < dateFixeEnvoiRapport || item.dernierEnvoiRapport == null)
                {
                    System.Diagnostics.Debug.WriteLine("Sending email to user" + item.UserName + "Time: " + System.DateTime.Now.ToLongTimeString());
                    //Envoyer le rapport
                    Boolean anglais = false;
                    if (item.Langue == "Anglais")
                    {
                        anglais = true;
                    }
                    string subject = "Rapport Mensuel pour l'utilisateur " + item.Prenom;
                    if (anglais)
                    {
                        subject = "your mensual report";
                    }
                    string body = "";

                    body += "Votre rapport<br>";
                    if (anglais)
                    {
                        body += "your report";
                    }
                    if (db.Encherees.Where(a => a.UserId == item.Id).Any())
                    {
                        var objets = db.Encherees.GroupBy(l => l.ObjetId).
                                     Select(g => g.OrderByDescending(c => c.UserId).FirstOrDefault()).
                                     Where(u => u.UserId == item.Id);

                        var listObjetAchete = objets.ToList();

                        body += "Nom de l'objet   |  date de vente <br>";
                        if (anglais)
                        {
                            body += "Object Name  |  Sale Date <br>";
                        }
                        foreach (var itemObjet in listObjetAchete)
                        {
                            body += itemObjet.objet.objetNom + " " + itemObjet.objet.objetDateInsc.AddDays(itemObjet.objet.objetDureeVente).ToLongDateString() + "<br>";
                        }

                        //var objets = db.Encherees.Where(a => a.UserId == UserId);
                        //return View(objets.DistinctBy(a => a.ObjetId).ToList());
                    }
                    else
                    {
                        body += "vous n'avez aucune enchère pour ce mois";
                        if (anglais)
                        {
                            body += "No report for this month";
                        }
                    }


                    Controllers.AccountController.EnvoiMessage(item.Email, body, subject);
                    item.dernierEnvoiRapport = dateFixeEnvoiRapport;
                    System.Diagnostics.Debug.WriteLine(body);
                    return;
                }
            }
        }
示例#41
0
 private void ErrorTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     ErrorText = "";
 }
示例#42
0
 private static void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     ParserRun();
 }
示例#43
0
 void JanitorTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     JanitorSweepUp();
 }
示例#44
0
 private void _timer_AutoCloseWindow(object sender, ElapsedEventArgs e)
 {
     Act = Act.Cancel;
     TryClose();
 }
示例#45
0
 private void graphicsTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     ProcessGraphics();
 }
        private void RemindDungeonMasterTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            TimeSpan timeSpanSinceCardPlay = DateTime.Now - timeActivated;

            DungeonMasterApp.TellDungeonMaster($"Reminder caulfielder: The \"{CardName}\" stampede card was activated {(int)timeSpanSinceCardPlay.TotalSeconds} seconds ago. Target the players/NPCs in the path and roll their dexterity saving throws!");
        }
示例#47
0
 private void physicsTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     ProcessPhysics();
 }
示例#48
0
        void transactionTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            List <Byte> packet     = null;
            int         startIndex = -1;
            int         endIndex   = -1;
            int         deviceID;

            transactionTimer.Stop();

            if (!spDriver.IsOpen)
            {
                throw new AndonManagerException("Serial Port Closed");
            }

            int bytesReceived = spDriver.BytesToRead;

            if (bytesReceived > 0)  //check whether bytes have been received
            {
                Byte[] tempBuff = new Byte[spDriver.BytesToRead];


                spDriver.Read(tempBuff, 0, bytesReceived); //copy the received bytes into temp buffer

                for (int i = 0; i < bytesReceived; i++)    //copy from temp buffer to packet
                {
                    rxPacket.Add(tempBuff[i]);
                }

                List <Byte> parsedRxPacket = xbeeDriver.parseRxPacket(rxPacket, out deviceID);
                if (parsedRxPacket == null)
                {
                    retries++;
                    if (retries >= NO_OF_RETRIES)
                    {
                        retries = 0;
                        rxPacket.Clear();
                        startTransaction();
                        return;
                    }
                    transactionTimer.Start();
                    return;
                }
                retries = 0;
                parsedRxPacket.InsertRange(0, partialPacket.GetRange(0, partialPacket.Count));
                partialPacket.Clear();

                while (parsedRxPacket.Contains(RESP_SOF) && parsedRxPacket.Contains(RESP_EOF))     // if the packet contains start of frame
                {
                    startIndex = parsedRxPacket.FindIndex(findRespSof);

                    endIndex = parsedRxPacket.FindIndex(findRespEof);

                    if (startIndex > endIndex)
                    {
                        parsedRxPacket.RemoveRange(0, startIndex);
                        continue;
                    }

                    packet = new List <byte>();
                    packet.AddRange(parsedRxPacket.GetRange(startIndex, (endIndex - startIndex) + 1));

                    processResponse(packet, deviceID);      //process it

                    parsedRxPacket.RemoveRange(0, endIndex + 1);
                }
                partialPacket.AddRange(parsedRxPacket.GetRange(0, parsedRxPacket.Count));
            }

            startTransaction();

            return;
        }
示例#49
0
 private void OnEventTimedEvent(Object source, ElapsedEventArgs e)
 {
     executePacketAndScheduleNext();
 }
示例#50
0
 private void CheckForSolution(object sender, ElapsedEventArgs e)
 {
     var solutionRequestMsg = new SolutionRequestMessage(_taskId);
     SendMessage(solutionRequestMsg.Serialize());
 }
示例#51
0
 public static void OnTimer(object source, ElapsedEventArgs e)
 {
     Console.WriteLine("Datetime: " + DateTime.Now);
     Console.WriteLine("Raised: {0}", e.SignalTime);
 }
示例#52
0
        //-->Event Handler

        /**
         * Timeout of the internal timer
         */
        void timeout(object sender, ElapsedEventArgs e)
        {
            //Handled by the controller class
        }
示例#53
0
文件: TimerM.cs 项目: tobelulu/OSDA
 private void SystemTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     SystemTime = SystemTimeData();
 }
示例#54
0
 /// <summary>
 /// fires each time the timer elapses
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     binding_Manager.LiveScreen.Dispatcher.Invoke(new Action(async() => { await UpdateScreens(); }), System.Windows.Threading.DispatcherPriority.ContextIdle);
 }
示例#55
0
 private void timer_elasped(object sender, ElapsedEventArgs e)
 {
     QueryLdap();
 }
示例#56
0
 /// <summary>
 /// 定时器
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     LoadDictionaries();
 }
        private void                                        MainCycle(object aSender, ElapsedEventArgs aEventArgs)
        {
            long lStartMS = MiscUtils.TimerMS;

            if (mDisconnect == false)
            {
                try
                {
                    mS7ProSim.GetState();

                    if (mItemList.Count != 0)
                    {
                        #region Item List Changed

                        if (mItemListChanged)
                        {
                            mItemRWList.Clear();
                            mItemListLock.EnterReadLock();
                            //========================================
                            try
                            {
                                mItemRWList.AddRange(mItemList);
                                mItemListChanged = false;
                            }
                            finally
                            {
                                //========================================
                                mItemListLock.ExitReadLock();
                            }

                            mQLength   = 0;
                            mQOptimise = true;
                        }
                        else if (mQOptimise)
                        {
                            mQOptimise = false;
                            optimise();
                        }

                        #endregion

                        if (mQLength > 0)
                        {
                            Task lQ = new Task(MC_Q_Read);
                            lQ.Start();

                            Task lIMDB = new Task(MC_IMDB_WriteRead);
                            lIMDB.Start();

                            Task.WaitAll(lQ, lIMDB);
                        }
                        else
                        {
                            int lCount = mItemRWList.Count;

                            for (int i = 0; i < lCount; i++)
                            {
                                mCurrentItem = mItemRWList[i];

                                if (mDisconnect)
                                {
                                    break;
                                }

                                #region Write

                                if (mCurrentItem.mNeedWrite)
                                {
                                    mWriteRequests = mWriteRequests + 1;
                                    mCurrentItem.write(mS7ProSim);
                                }

                                #endregion

                                if (mDisconnect)
                                {
                                    break;
                                }

                                #region Read

                                if (mCurrentItem.mNeedWrite != true)
                                {
                                    mCurrentItem.read(mS7ProSim);
                                }

                                #endregion

                                if (mDisconnect)
                                {
                                    break;
                                }

                                mSlowCounter = mSlowCounter + mDeltaSlow;
                                if (mSlowCounter >= 1.0D)
                                {
                                    mSlowCounter = mSlowCounter - 1.0D;
                                    Thread.Sleep(MiscUtils.TimeSlice);
                                }
                            }

                            mCurrentItem = null;
                        }
                    }
                }
                catch (Exception lExc)
                {
                    mDisconnect = true;
                    raiseConnectionError(lExc.Message);
                }
            }

            mMainCycleTimeMS = MiscUtils.TimerMS - lStartMS;

            if (mDisconnect)
            {
                mS7ProSim.EndScanNotify();
                mS7ProSim.Disconnect();

                mConnected = false;
                raiseConnectionState();
                mCycleEndEvent.Set();
                mDisconnectEvent.Set();
            }
            else
            {
                mMainCycleTimer.Start();
                mCycleEndEvent.Set();
            }
        }
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     this.Open();
 }
 ////////////////////////////////////////////////////////////////////////////////
 ///	@brief			タイマーイベント
 ///	@fn				void OnTimedEvent(object source, ElapsedEventArgs e)
 ///	@param[in]		object source
 ///	@param[in]		ElapsedEventArgs e
 ///	@return			ありません
 ///	@author			Yuta Yoshinaga
 ///	@date			2017.10.20
 ///
 ////////////////////////////////////////////////////////////////////////////////
 private void OnTimedEvent(object source, ElapsedEventArgs e)
 {
     Dispatcher.Invoke(new Reversi_ResizeEndDelegate(this.Reversi_ResizeEnd), source, e);
 }
示例#60
0
        private async void Work(object sender, ElapsedEventArgs e)
        {
            if (Conf == null)
            {
                return;
            }
            timer.Interval = Conf.Interval * 60 * 1000;
            if (Interlocked.Read(ref runFlag) == 0)
            {
                return;
            }
            Log.Info($"[{Name}] do work ...");
            try
            {
                //获取本机公网IP
                string realIp = "";
                if (Conf.GetIpUrls.Count == 0 && Conf.IsIpV6)
                {
                    //IPCONFIG
                    realIp = NetWorkUtils.GetLocalIpV6Address();
                }

                if (Conf.GetIpUrls.Count == 0 && !Conf.IsIpV6)
                {
                    Conf.GetIpUrls.Add(DEFAULT_IP_V4_URL);
                }

                if (Conf.GetIpUrls.Count > 0)
                {
                    foreach (string url in Conf.GetIpUrls)
                    {
                        var getRes = await url.Get();

                        if (!getRes.Ok)
                        {
                            Log.Info($"[{Name}] fetch real internet ip from {url} fail , try next url");
                            continue;
                        }

                        Match mc;
                        //提取IPV6地址
                        if (Conf.IsIpV6)
                        {
                            mc = IpV6Regex.Match(getRes.HttpResponseString);
                        }
                        //提取IPV4地址
                        else
                        {
                            mc = IpV4Regex.Match(getRes.HttpResponseString);
                        }

                        if (mc.Success && mc.Groups.Count > 0)
                        {
                            realIp = mc.Groups[0].Value;
                            Log.Info(
                                $"[{Name}] fetch real internet ip from ( {url} ) success, current ip is ( {realIp} )");
                            break;
                        }
                    }
                }

                if (string.IsNullOrWhiteSpace(realIp))
                {
                    Log.Info($"[{Name}] fetch real internet ip all failed, skip");
                    return;
                }

                // double check
                if (!realIp.IsIpAddress())
                {
                    Log.Info($"[{Name}] fetch real internet ip [{realIp}] is not a valid ip address, skip");
                    return;
                }

                //double check
                if (Conf.IsIpV6 && !realIp.IsIpV6Address())
                {
                    Log.Info($"[{Name}] fetch real internet ip [{realIp}] is not a valid ipv6 address, skip");
                    return;
                }

                //获取阿里云记录
                var describeRes = await new DescribeDomainRecordsRequest(Conf.AccessKeyId, Conf.AccessKeySecret)
                {
                    DomainName  = Conf.DomainName,
                    RRKeyWord   = Conf.SubDomainName,
                    TypeKeyWord = Conf.Type,
                }.Execute();
                if (describeRes.HasError)
                {
                    Log.Info($"[{Name}] describe domain records fail ( {describeRes.Message} ) , skip");
                    return;
                }

                //未查到记录,添加
                if (describeRes.TotalCount == 0)
                {
                    goto ADD;
                }

                foreach (var record in describeRes.DomainRecords.Records)
                {
                    //fix https://github.com/xuchao1213/AliyunDdnsCSharp/issues/3
                    if (record.Type == Conf.Type && record.RR == Conf.SubDomainName)
                    {
                        if (record.Value == realIp)
                        {
                            Log.Info($"[{Name}] ip not chanage , skip");
                            return;
                        }
                        //
                        //update
                        Log.Info($"[{Name}] prepare to update domain record ...");
                        var updateRes = await new UpdateDomainRecordRequest(
                            Conf.AccessKeyId, Conf.AccessKeySecret)
                        {
                            RecordId = record.RecordId,
                            RR       = Conf.SubDomainName,
                            Type     = Conf.Type,
                            Value    = realIp,
                            TTL      = Conf.TtlV,
                            Line     = Conf.Line,
                        }.Execute();
                        Log.Info(updateRes.HasError
                            ? $"[{Name}] update domain record fail ( {updateRes.Message} ) , skip"
                            : $"[{Name}] update domain record ok , now  record value is {realIp}");
                        if (updateRes.HasError)
                        {
                            return;
                        }

                        //更新成功后,暂停解析->启用解析,以此来解决更新后不立即生效的问题
                        var disableRes = await new SetDomainRecordStatusRequest(
                            Conf.AccessKeyId, Conf.AccessKeySecret)
                        {
                            RecordId = updateRes.RecordId,
                            Enable   = false
                        }.Execute();
                        Log.Info(disableRes.HasError
                            ? $"[{Name}] set domain records status to disable error ( {disableRes.Message} ) , skip"
                            : $"[{Name}] set domain records status to disable ok , now enable it");
                        if (disableRes.HasError)
                        {
                            return;
                        }

                        var enableRes = await new SetDomainRecordStatusRequest(
                            Conf.AccessKeyId, Conf.AccessKeySecret)
                        {
                            RecordId = updateRes.RecordId,
                            Enable   = true
                        }.Execute();
                        Log.Info(enableRes.HasError
                            ? $"[{Name}] set domain records status to enable error ( {enableRes.Message} ) , skip"
                            : $"[{Name}] set domain records status to enable ok , just enjoy it :)");
                        return;
                    }
                }

ADD:
                {
                    //add
                    Log.Info($"[{Name}] prepare to add domain record ...");
                    var addRes = await new AddDomainRecordRequest(
                        Conf.AccessKeyId, Conf.AccessKeySecret)
                    {
                        DomainName = Conf.DomainName,
                        RR         = Conf.SubDomainName,
                        Type       = Conf.Type,
                        Value      = realIp,
                        TTL        = Conf.TtlV,
                        Line       = Conf.Line,
                    }.Execute();
                    Log.Info(addRes.HasError
                        ? $"[{Name}] add domain record fail ( {addRes.Message} ) , skip"
                        : $"[{Name}] add domain record ok , now  record value is {realIp}");
                }
            }
            catch (Exception ex)
            {
                Log.Warn($"[{Name}] do work exception : {ex.Message}");
            }
        }