none
can someone help with a delay and label problem RRS feed

  • Question

  • well i want to show the time in an up to date type mode like a digiatal clock but seems unable to print it onto a label fast enough (and yes it is messy as it is my first program i am making.) oh and if this is in the wrong forum just tell me politely and dont ram unsightful comments down my throat please. any tips? The code is as follows  (using C#) .....

    using System;
    
    
    
    using System.Collections.Generic;
    
    
    
    using System.ComponentModel;
    
    
    
    using System.Data;
    
    
    
    using System.Drawing;
    
    
    
    using System.Linq;
    
    
    
    using System.Text;
    
    
    
    using System.Windows.Forms;
    
    
    
    using System.Threading;
    
    
    
    
    
    
    
    namespace Date.time
    
    
    
    {
    
    
    
     //main form
    
    
    
     public partial class Form1 : Form
    
    
    
     {
    
    
    
     public Form1()
    
    
    
     {
    
    
    
     InitializeComponent();
    
    
    
     }
    
    
    
     // time button
    
    
    
     private void timebtn_Click(object sender, EventArgs e)
    
    
    
     {
    
    
    
     // loop ammount of times
    
    
    
     for (int count = 0; count <= 4; count++)
    
    
    
    
    
    
    
     { // find time
    
    
    
     DateTime thismoment = DateTime.Now;
    
    
    
    
    
    
    
      
    
      TimeLab.Text = thismoment.ToString("T");
    
    
    
    
    
    
    
     // sleep in milliseconds
    
    
    
     Thread.Sleep(1000);
    
    
    
    
    
    
    
     }
    
    
    
    
    
    
    
     }
    
    
    
     // date button
    
    
    
     private void DateBtn_Click(object sender, EventArgs e)
    
    
    
    
    
    
    
     { // find date
    
    
    
     DateTime thismoment = DateTime.Now;
    
    
    
    
    
    
    
     // display on label Datelab
    
    
    
     DateLab.Text = thismoment.Date.ToString("d");
    
    
    
    
    
    
    
     }
    
    
    
     }
    
    
    
    }
    
    
    
    
    • Edited by sovietspud Monday, July 12, 2010 11:08 AM forgot something
    Monday, July 12, 2010 11:05 AM

Answers