I am writing a C # program to display the temperature of a CPU / GPU from my PS3. There is a connect button. This works very well, and it shows me Temp. from my PS3 CPU / GPU.
Now I have implemented the Refresh button, which starts the timer for all x seconds for this:
public void get_psdata() {
So, this "get_psdata" only works the first time I click the connect button. (The connection button launches the get_psdate function directly, and the update button is slightly different, as you can see later ...)
Here is the code to run get_psdata:
//B_connect, Connect Button private void b_connect_Click(object sender, EventArgs e) { //Connect CCAPI to PS3 if Button clicked PS3.ConnectTarget(psip); //Check Connection if (PS3.SUCCESS(PS3.ConnectTarget(psip))) { //Show Status MessageBox.Show("Connected to: " + psip + "!"); this.L_status_show.Text = "Connected!"; L_status_show.ForeColor = System.Drawing.Color.Green; //Call Function get_psdata(); } else { //Show Status MessageBox.Show("Failed to Connect to: " + psip + "!"); this.L_status_show.Text = "Not Connected!"; L_status_show.ForeColor = System.Drawing.Color.Red; } }
For testing, I added Messagebox.Show to the "get_psdata" function to find out if it works for all x seconds ... Yes, and this is my timer:
//Function to set refresh delay public void refresh_delay() { MessageBox.Show("Delay set to " + refresh_int + " Seconds!"); refresh_int = refresh_int * 1000; //Change to Miliseconds init_timer(); } //Timer public Timer timer1; public void init_timer() { timer1 = new Timer(); timer1.Tick += new EventHandler(timer1_Tick); timer1.Interval = refresh_int; // in miliseconds timer1.Start(); } public void timer1_Tick(object sender, EventArgs e) { get_psdata(); }
And here is what my timer starts:
//B_set, Set refresh time button private void B_set_Click(object sender, EventArgs e) { //Check refresh Value refresh_string = TB_refresh.Text; //Check empty if (refresh_string != "") { //Check minimum refresh_int = Convert.ToInt32(TB_refresh.Text); if (refresh_int < 5) { DialogResult confirm = MessageBox.Show("This is not the delay you are looking for! \r (I recommend to set it bigger then 5) \r Continue with " + refresh_int + " Seconds?", "Realy dude?", MessageBoxButtons.YesNo); if (confirm == DialogResult.Yes) { //Call Function refresh_delay(); } } else { //Call Function refresh_delay(); } } else { MessageBox.Show("Please set refresh delay!"); } }
Thus, I am sure that the code will start all x seconds, but the label will be updated only after I press the connect button, but not if I started the counter after connecting using the B_set button.
The variables from "get_psdata" do not show the updated value. They just show the result from the first "Get". Why don't they show the last result?