Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8428953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:11:58+00:00 2026-06-10T05:11:58+00:00

I have VS2010 and I’m working on a windows form application. So, I have

  • 0

I have VS2010 and I’m working on a windows form application.

So, I have threads created dynamically (depending on user input), the processing for these threads can take quiet a while (days in extreme cases). So I’ve put a button on the form and want to be able to ‘pause’ or ‘suspend’ the threads. I’ve looked up the .suspend method and it has been replaced (I’ve tried using it but it does fail sometimes – causing the UI to crash) so the new method for doing this that I’ve found is ‘waithandle’. I’ve read the documentation for this and I can’t work out how to use it.

This is the basic structure of each of the threads:

Do
     'time consuming operations
loop 'a number of times

Then in a separate button I want to put the pause code. It’s not all that important that it’s paused quickly, pausing on the next run through the loop is fine (each run through is quite quick, it just does it hundreds of times). I’m assuming I have to put the waithandle check at the start of the loop but I don’t actually know how to implement this. This is my waithandle dim code:

Dim waitHandles As System.Threading.EventWaitHandle = New System.Threading.AutoResetEvent(True)

All threads are to be paused at once (except the main UI thread) so I think that means I only need one wait handle but I’m not sure about this.

Anyway, if anyone can just tell me what code goes into the do loop and what goes into the pause button I think I can work through everything else. 🙂

Many thanks!

Fraser


From Comments:

Thanks! I got it working. Here’s my implimentation:

Dim mre As New System.Threading.ManualResetEvent(True)

(that’s at the top of the code (just under ‘public class form 1’)
then in the threading it has:

mre.WaitOne(), 

finally in the button that pauses/unpauses the thread it has:

mre.Reset() 'to resume the threads and, mre.Set() 'to pause the threads 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:11:59+00:00Added an answer on June 10, 2026 at 5:11 am

    Use a ManualResetEvent for this. An AutoResetEvent is ‘almost a semaphore’ in that you would have to signal it as many times as you have threads that are waiting – this can become awkward under some circumstances.

    Create the event signaled, (ie set), and wait on it in your threads at a suitable point where the system call to wait will have a negligible impact on the loops in your threads, ie. maybe not in an innermost loop.

    Clear the event in your ‘Pause’ button OnClick(), set it in your ‘Resume’ OnClick().

    Sorry, no actual code ‘cos I don’t have any VB, but it should be easy to do 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi want to develop a windows phone application. I have vs2010 ultimate installed in
I have a VS2010 project which is a windows application that acquires data from
I have installed VS2010 and MVC2 and testing a simple form using tinyMCE. When
I have a .bat file that publishes my VS2010 application, then copies the files
We have a .NET application (VB / VS2010) and are calling many stored procedures
I have VS2010 Premium RTM version on Windows 7 Ultimate x64 . In the
I have vs2010 ultimate installed and sql server 2008 developer. I created a package
I have VS2010 Ultimate and i want to create a Windows Azure Project However
I have a VS2010 Winforms project with several forms and user controls, all integrated
I have a VS2010 solution with several projects in it. These projects are winforms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.