My Pause button doesn't work

Posted on 2013-10-06
Medium Priority
Last Modified: 2013-10-06
Please excuse me if I'm missing something really stupid, but this is my first widows forms application in a long time.

I have a form with several controls for setting params and three buttons (BEGIN, PAUSE, and RESUME) to control the action. the BEGIN button uses the params to do some lengthy processing with thousands of records. I want the PAUSE button to allow the user to pause the action until the user presses the RESUME button.

The problem is that once the processing starts the form no longer responds the clicking on the buttons? I do similar things in other programming environments, but this one has me stumped...

Thanks, Lippert
Question by:lippert
  • 2
LVL 64

Accepted Solution

Fernando Soto earned 2000 total points
ID: 39550883
Hi lippert;

The Microsoft Windows Form environment works as a single thread of operations. When the application starts it start something called the message pump. This message pump holds all the events that needs attention such as Button click events Textbox Text events and many other such type events. As each event is taken off the message pump the code in that event gets executed and when that event completes its task it gets the next event and processes it until there is no more events to be processed and just sits there just waiting for the next event to happen. So when you click the Begin button that code gets executed and no other events can get processed until it has completed. The result of this is that your form becomes unresponsive to the user. If you want to be able to interrupt the process then you will need to introduce another thread to handle the processing of the code that you placed in that button click event by moving it from the button click event handler to the new thread.  A couple of  examples of this can be seen in the, BackgroundWorker Class, At the bottom of the page you will see an example.

Author Closing Comment

ID: 39550914
Perfect answer, coherent and complete.... Thanks.
LVL 64

Expert Comment

by:Fernando Soto
ID: 39550973
Not a problem, glad I was able to help.  ;=)

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question