Ask God to two problems, one is how to determine the thread timer has no refresh

Ask you two questions.:
Prerequisites: I want to be a and each detection station network program, I use the multi thread, a detection station a thread, each detection station is to refresh the data in label, 10s refresh time. Need to do is to let each detection station are independent of each other, a data card out does not affect other inspection station, a data detection station 3 minutes without refresh to restart this thread, as shown in Fig.
The first question is:
I wrote a monitoring program now (with help), only more than three minutes, but no judgment for three minutes if refresh thread, so would like to ask how to judge God I this thread three minutes is set, each thread has a timer timer, 10s refresh time.
The following code:
Definition:
Dictionary<int, DateTime> source = new Dictionary<int, DateTime>();
private TimerCallback ti;


FORM load program
private void frmMain_Load(object sender, EventArgs e)
        {
            EQ2008Config.GetSection();
            string strpath = AppDomain.CurrentDomain.BaseDirectory + "\\StationConfig.xml";
            XmlDocument doc = new XmlDocument();//Initialize an instance of XML
            doc.Load(strpath);//Import the XML file specified
            XmlNode no = doc.SelectSingleNode("StationList");//Specify a node
            XmlNodeList listnode = no.SelectNodes("StationData");//Gets the same level "stationdata" node set
            
            ti = new TimerCallback(ShowDataToScreenStation);
            //System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
           
            foreach (XmlNode node in listnode)//Iterate through all the stationdata nodes
            { 
                weituo = new WeiTuo<XmlNode>(Set_labelText);
                StartThread(node);
            }
         //Below is a monitoring program  
            Thread jiankong = new Thread(()=>{
               while (true) 
               {
                   foreach(var item in source)
                   {
                       if((DateTime.Now - item.Value)>TimeSpan.FromSeconds(180))//Judge exceeded three minutes how to judge whether the timer refresh.? ? ? ? 
                       {
                           if (sf_event != null) 
                               this.sf_event(item.Key);
                       }
                   }
                   Thread.Sleep(5000);//Monitoring thread 5 seconds to execute a
               }
            });
            jiankong.IsBackground = true;
            jiankong.Start();
}


Function to generate label, which has a timer, 10s refresh a data
public void Set_labelText(XmlNode strText) 
        {
            this.Invoke((Action<XmlNode>)delegate(XmlNode node)
            {
                StationData stationData = new StationData(node);
                source.Add(stationData.CardFlagID, DateTime.Now);
                //stationData.IsShow = false;
                Program.listStationList.Add(stationData);
                this.flowLayoutPanel1.BackColor = Color.Orange;
                Label lab = new Label();//An instance of a label display

                lab.Name = "lab" + stationData.CardFlagID.ToString();
                lab.AutoSize = false;
                lab.Size = new Size(280, 140);
                lab.BorderStyle = BorderStyle.Fixed3D;
                lab.Text = stationData.StatinName;
                lab.Font = new Font("Times New Roman", 11);

                if (stationData.IsShow)
                {
                    lab.BackColor = Color.Green;
                }
                if (stationData.IsShow)
                {
                    System.Threading.Timer tim = new System.Threading.Timer(ti, stationData.CardFlagID, 0, 10000);
                    //More than 0 seconds, and then every 10 seconds, will be called by a TimerCallback (ShowDataToScreenStation) the specified delegate. 
                    //Every 10 seconds, refresh a data detection station
                    dicThread.Add(stationData.CardFlagID.ToString(), tim);
                }
                this.flowLayoutPanel1.Controls.Add(lab);
            }, strText);
        }


The following is a function of the creating thread
        void StartThread(XmlNode x)
        {
            Thread a = new Thread(() =>{
                Set_labelText(x);
            });
            a.IsBackground = true;
            a.Start();
            this.sf_event += (ids) => {
                a.Abort();
                a = new Thread(() =>
                {
                    Set_labelText(x);
                });
                a.IsBackground = true;
                a.Start();
            };//The registered event
        }



Asked the first question! Please thank you God!

Started by Reed at February 10, 2016 - 7:19 PM

this.sf_event += (ids) => {
a.Abort();
Set a parameter in the event, recording 3 minutes whether to call back off function -- that is to say the refresh.?
50 for you

Posted by Monica at February 19, 2016 - 7:50 PM

Definitely call, 10s calls again, in fact I was in judging the refresh on the death card, do not know how much hair put up, I'm going to judge whether to perform refresh function after the judge now, is that you just answer my question in another post!

Posted by Reed at February 23, 2016 - 8:19 PM

Weak weak ask for me.

Posted by Monica at March 04, 2016 - 8:40 PM

Defining a delegate, as defined in the main thread and Zi Xiancheng, after the child thread to refresh, calls this delegate function will know

Posted by Angelo at March 06, 2016 - 9:28 PM

See you in Neusoft, I have to give!!!

Posted by Reed at March 10, 2016 - 9:51 PM

Just had a look around, you can be divided into 10
Give me is it right? You are negative, or simply can't give me.

Posted by Monica at March 12, 2016 - 10:38 PM

No or looking at me character.

Posted by Monica at March 13, 2016 - 10:46 PM

Master, you see another post, me, thank you!

Posted by Reed at November 17, 2016 - 1:49 PM

Who let I was Neusoft.?

Posted by Reed at November 26, 2016 - 2:30 PM

I divided all pressure in the post, can be divided into: of course not, send these days are all about multi thread posts!

Posted by Reed at November 27, 2016 - 3:26 PM

Write a global variable, to add 1

Posted by Jeff at December 08, 2016 - 3:39 PM

I change the way now, is to determine the number of executed without refresh function, more than 5 times on the restart, but mine is multithreaded, judge for the completion of the execution times here always wrong, because multiple threads is a function with a call to refresh! Here the card is dead!

Posted by Reed at December 18, 2016 - 4:34 PM

Fate.

I also long thread project
Feel to learn very much

Posted by Monica at December 23, 2016 - 5:20 PM

I used in the Neusoft are doing C, just contact c# multi thread! Feel do not come out!

Posted by Reed at December 28, 2016 - 5:47 PM

I graduated 06 years.

Posted by Monica at January 02, 2017 - 6:56 PM

I graduated 06 years.

Posted by Monica at January 05, 2017 - 5:56 PM

I graduated 06 years.

Posted by Monica at January 14, 2017 - 6:51 PM