Martin,
You could create a thread yourself and call GetFiles on that thread, and
then marshal the file information back to the UI thread. If the user aborts
the process, then you can just call Abort on the thread. It's not going to
abort immediately, as it will wait for the calls to the P/Invoke layer to
complete, but once the code exits back to managed code, the
ThreadAbortException will be thrown and the thread will stop processing.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:e3*************@TK2MSFTNGP06.phx.gbl...
Hi!
Is there any way to abort the process of GetFiles method?
I have a Method that will scan thousands of files and directories. But the
user will be able to abort this process, which i fully understand.
I do use a BackgroundWorker to be able to cancel to process, but since the
GetFiles don't ever leave the method until all the files has been found
that
i told it to do, i cant process the BackgroundWorker.Cancelpending.
Any ideas?
Regards
Martin