pause

Discussion in 'Microsoft C# .NET' started by RobcPettit@yahoo.co.uk, May 23, 2006.

  1. Guest

    Hi, Ive got a text box on a form and my program collect values. When
    its running id like it to update my text box after each 50 values. How
    do I get the program to pause, update the textbox then continue. I can
    do the count ok, and get the values it doesnt update the textbox
    though. I using if( x - y == 50) textbox = etc.
    Regards Robert
     
    , May 23, 2006
    #1
    1. Advertisements

  2. Marc Gravell Guest

    In a tight loop (which it sounds like you are) the nasty way is to call
    Application.DoEvents(); after each 50.

    This gets the job done, but isn't really nice; a better (but more complex)
    way involves using a background thread and eventing, or a background worker
    component (which does the same under the bonnet).

    Marc
     
    Marc Gravell, May 23, 2006
    #2
    1. Advertisements

  3. Guest

    Thanks for a quick response, Ill have a read up on background threads.
    Regards Robert
     
    , May 23, 2006
    #3
  4. Marc Gravell Guest

    Fair enough...

    Also - I kinda assumed in your original post that the textbox itself wasn't
    the problem; using the grungy DoEvents() approach, this would look something
    like:

    int counter = 0;
    while(someLoopCondition) {
    DoSomethingInteresting();
    counter++;
    if(counter % 50 == 0) {
    someTextBox.Text = counter.ToString();
    Application.DoEvents(); // hate hate hate
    }
    }

    Marc
     
    Marc Gravell, May 23, 2006
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    Console "Pause"

    Guest, Nov 22, 2003, in forum: Microsoft C# .NET
    Replies:
    4
    Views:
    236
    news.microsoft.com
    Nov 24, 2003
  2. Ken Brannigan

    Pause Code While Form Processes Without Using Modal

    Ken Brannigan, Jan 19, 2004, in forum: Microsoft C# .NET
    Replies:
    7
    Views:
    299
    Dmitriy Lapshin [C# / .NET MVP]
    Jan 21, 2004
  3. C# Learner

    Creating a Pause in Execution

    C# Learner, Jan 31, 2004, in forum: Microsoft C# .NET
    Replies:
    19
    Views:
    551
    C# Learner
    Feb 1, 2004
  4. Wim

    How to pause/suspend a process?

    Wim, Feb 1, 2004, in forum: Microsoft C# .NET
    Replies:
    8
    Views:
    1,031
  5. kids_pro

    Pause process and kill it

    kids_pro, Mar 30, 2004, in forum: Microsoft C# .NET
    Replies:
    3
    Views:
    3,421
    Dmitriy Lapshin [C# / .NET MVP]
    Mar 30, 2004
Loading...

Share This Page