Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3780

Kill Preemptive thread long process FolderItem.CopyTo

$
0
0

I was waiting for a long time a FolderItem.CopyTo which does not freeze the UI (it does even if it is in a Cooperative Thread). Some weeks ago I added an option in my application to copy using a Shell command via a Shell Asynchronous and it works.
But as Xojo just added Preemptive Thread I modified my program to make the FolderItem.CopyTo in a Preemptive Thread.
It woks as expected, but if the user click a Stop button, I kill the Thread with MyPreemptiveThread.Stop . But then my application is freezed until the copy is finished! (it is as before when I copy my file in a Cooperative Thread).

Note: I synchronise 2 folders in a loop inside a Cooperative Thread called TreadSync. When I see a file to be copied, I run the Preemptive Thread called ThreadCopy which copy the file and I do ThreadSync.Pause . ThreadCopy do ThreadSync.Resume at its end (once the file is copied).
If the user click Stop, I put a Flag to true, I do ThreadCopy.Stop end ThreadSync.Resume which will exit the loop as the StopFlag is True.

I will make a sample project with a loop in a Preemptive Thread and kill it.

12 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 3780

Trending Articles