windows form not responding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Syed Hadi
    New Member
    • Dec 2012
    • 56

    windows form not responding

    Code:
      string scrolltext = "Note -: This survey has been designed to determine your level of satisfaction with Administration Affairs Dept services. Your participation in this survey is important as it helps us to identify any areas of concern with our services and helps us to continuously review and improve the services we bring to u!!!!!!!!";
    
                //string Lyrics = "This song is just six words long";
                int CurrentPosition = 0;
                const int CharactersToShow = 100;
               
                  for (int i = 0; i < scrolltext.Length; i++)
                {
                    label2.Text = CharactersToShow + CurrentPosition > scrolltext.Length
                                ? scrolltext.Substring(CurrentPosition)
                                : scrolltext.Substring(CurrentPosition, CharactersToShow);
                    CurrentPosition++;
                    label2.Update();
                   thread.sleep(250);
                }
    for the above loop i am using thread . that scrooling is fine but i cant able tou use other function like in the form textboxes are ther when i am clicking the textbox the form is geting stuck the reason showing is not responding . i am not getting why it is happining can any body suggest me where m wrong
  • beacon
    Contributor
    • Aug 2007
    • 579

    #2
    Is that all of your code? Have you debugged your code to see what lines of code processed prior to the form entering the 'Not Responding' state?

    I'm no expert, but you may be having trouble because either (1.) your thread isn't allowing for enough time in relation to the progress you're trying to update on the label or (2.) the progress/update isn't actually being performed in a separate thread.

    Like I said, I'm not expert and my responses are guesses based on my own very limited personal experience. I ran into something similar in a recent project and I ended up using the BackgroundWorke r instead...I think, based on what I read at the time, that it's considered by most people to be the preferred method when threading (depending, of course, on your version of .NET, which you didn't specify).

    Comment

    • Syed Hadi
      New Member
      • Dec 2012
      • 56

      #3
      firstly thanks beacon...may be your guess will bi right .. ill go through that one but for rite now i am using timer instead of thread...

      Comment

      Working...