+ Post New Thread
Results 1 to 3 of 3
Coding Thread, c# label not immediately updating in Coding and Web Development; A mate of mine is having the following issue with his coursework, it has me stumped, so I was wondering ...
  1. #1
    mrcrazy04's Avatar
    Join Date
    Nov 2006
    Location
    Bedfordshire/Cheltenham, UK
    Posts
    258
    Thank Post
    2
    Thanked 11 Times in 11 Posts
    Rep Power
    17

    Question c# label not immediately updating

    A mate of mine is having the following issue with his coursework, it has me stumped, so I was wondering if anybody had any suggestions!

    Seemingly simple command, trying to show the text "Making noise" whenever an animal in my Zoo program makes a noise. It doesn't seem to use that text though, instead it will run whatever method is selected, but will seemingly stay as "Nothing" in my label. If I get rid of the "Nothing" at the end of the if/elses, it will change to "Making noise" after my methods have run.

    Code:
            private void btnNoise_Click(object sender, EventArgs e)
            {
                labState.Text = "Making noise";
                //System.Threading.Thread.Sleep(500);
    
                if ((radCats.Checked) && (radOne.Checked))
                {            
                    Zoo[0].MakeNoise();
                }
                else
                if ((radCats.Checked) && (radTwo.Checked))
                {
                    Zoo[1].MakeNoise();
                }
                else
                if ((radDogs.Checked) && (radOne.Checked))
                {
                    Zoo[2].MakeNoise();
                }
                else
                if ((radDogs.Checked) && (radTwo.Checked))
                {
                    Zoo[3].MakeNoise();
                }
                else
                if ((radTigers.Checked) && (radOne.Checked))
                {
                    Zoo[4].MakeNoise();
                }
                else
                {
                }
                //System.Threading.Thread.Sleep(500);
                labState.Text = "Nothing";
            }

    Also, the MakeNoise() method isn't instantly over, there are System.Threading.Thread.Sleeps in those too.

  2. #2
    bizzel's Avatar
    Join Date
    Jul 2007
    Location
    Cambridge
    Posts
    654
    Thank Post
    102
    Thanked 204 Times in 72 Posts
    Rep Power
    51
    If makeNoise runs in the same thread then the interface might only update after the sound has played. Ideally you'll need to have a new thread for the sound and launch that.

  3. #3
    budgester's Avatar
    Join Date
    Jan 2006
    Location
    Enfield, Middlesex
    Posts
    486
    Thank Post
    4
    Thanked 37 Times in 30 Posts
    Rep Power
    24
    Can you do a window repaint/refresh of something like that ?

SHARE:
+ Post New Thread

Similar Threads

  1. Label Printing in Libraries
    By moggy in forum Hardware
    Replies: 6
    Last Post: 9th November 2008, 02:37 PM
  2. [News] Effective Immediately
    By mattx in forum Jokes/Interweb Things
    Replies: 1
    Last Post: 30th October 2008, 02:44 PM
  3. Label Printer
    By flyinghaggis in forum Hardware
    Replies: 2
    Last Post: 15th February 2008, 06:00 PM
  4. Windows Product Key label
    By timbo343 in forum Windows
    Replies: 15
    Last Post: 23rd July 2007, 10:29 PM
  5. Can anyone recommend a CD label printer?
    By paulpmp4 in forum Hardware
    Replies: 3
    Last Post: 12th February 2007, 06:48 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •