Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Sep 20, 2018 11:56 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Threads and Progress Bars - Ready to do it Right
PostPosted: Mon Mar 25, 2013 1:10 pm 
Offline
User avatar

Joined: Wed Feb 01, 2012 3:06 pm
Posts: 68
Kem -

Back for one more lesson, please... Regarding the following:
Sub StartImport()
If ProcessThread <> nil and ProcessThread.State <> Thread.NotRunning then
ProcessThread.Kill
while ProcessThread.State <> Thread.NotRunning
App.YieldToNextThread
wend
end if

ProcessThread = new MyProcessThread
ProcessThread.Run
MonitorTimer.Mode = 2
End Sub

I am intrigued with your start up code where you check to see if the process is already running and, if so, you kill the thread and wait for it to terminate before proceeding.

I'm assuming that was also a lesson learned and can see where it makes a lot of sense to make sure that the process is not already running before starting another thread. However, what is most curious is why you kill the process rather than just waiting for it to complete.

Thank you for all you time and effort.\
Ron Bower

_________________
Ron Bower
Ellicott City, MD


Top
 Profile  
Reply with quote  
 Post subject: Re: Threads and Progress Bars - Ready to do it Right
PostPosted: Mon Mar 25, 2013 3:26 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
It all depends on what you're thread is doing, and when/why you're starting a new one. If you are going to let the first finish anyway, there is no need to kill it, just start the second to run side-by-side with it.

My version applies when the circumstances that lead to launching the initial thread have changed. For example, in RegExRX, as someone types a regular expression pattern, a thread starts to run the search and do additional processing. Let's say someone types "a", then, a second later, types "b" (making the full pattern "ab"). In that case, it doesn't make sense for the first thread to be allowed to finish because, now, it's just wasting time, so the right course is to kill it and replace it. That's what that code is all about.

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
 Post subject: Re: Threads and Progress Bars - Ready to do it Right
PostPosted: Mon Mar 25, 2013 3:36 pm 
Offline
User avatar

Joined: Wed Feb 01, 2012 3:06 pm
Posts: 68
Okay, Kem, that was the last thing I needed to wrap it up for now.

I have the thread processing down fairly well now and have converted three time consuming processes to threads - all working well.

Thanks again !

Ron Bower

_________________
Ron Bower
Ellicott City, MD


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group