Skip to content

Pause / Stop a method

Chris

Asked Apr 16, 2008, 6:58 AM EDT1 answer
Share
LinkedInX

I have an application that searches through log files for a string match.  Its not uncommon that I'm searching through hundreds of files at a time, and sometimes I want to pause or stop the search.

How can I implement a pause or stop function that pauses/stops the 'Search' method, for example?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    You can use threads in the application, put the main app on one thread and the search on another. then from the main thred you can tell the search thread to sleep when you want it to pause.

    System.Threading.Thread.Sleep(time);

    MSDN: here
    Thread Sleep: here
    0