How to keep an active "Stop button" while application is reading file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bjoarn

    How to keep an active "Stop button" while application is reading file

    I have an Application C# handling file reading, building index on this file, using dll wrapped with SWIG. The dll is originaly programmed in C++.

    Dll reports back to the the C# programm throug callback/delegates. Among others, it reports index building(%). One callback function can receive (stop order) to stop reading file/building index. How ever i do not know how to keep the stopbutton activ while this file reading is going on.

    I have not tried threading before.

    Can I keep this one button active running it on a separete thread ?
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    #2
    If your read is happening in a loop, try Application.DoE vents(), it'll force the application to flush all pending actions. The other option is to run the read process in it's own thread, or a background worker.

    Comment

    Working...