It is currently Fri May 24, 2013 6:00 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: How to do independent progress bar?
PostPosted: Fri Apr 13, 2012 8:45 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 578
Location: germany
I have to call a DLL function which uses up to 20 seconds. I want to give the user some feedback, that it is still working. No, there is no callback for that DLL function.

I thought about adding a simple ProgressBarGadget() and using a thread to update the status. If the DLL is finished, I can terminate the thread and remove the progress bar. So far, the idea is easy, but I think I will have problems updating a gadget from a thread, right? Is it a risk to try to update the progress bar using SetGadgetState() from inside a thread (cross plattform)? Or is this absolutely ok?

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
 Post subject: Re: How to do independent progress bar?
PostPosted: Fri Apr 13, 2012 8:51 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
Don't know if this will help you but I was able to do it without a thread on OS X. Read last post here...
viewtopic.php?f=13&t=47122&hilit=progressbar

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Top
 Profile  
 
 Post subject: Re: How to do independent progress bar?
PostPosted: Fri Apr 13, 2012 12:36 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Apr 30, 2003 8:15 am
Posts: 710
Location: Germany
I guess it will be OK. I did this in several cases with no problems (but windows only).
For more safety, you can open a new window inside the thread and create the gadget there.

_________________
"Daddy, I'll run faster, then it is not so far..."


Top
 Profile  
 
 Post subject: Re: How to do independent progress bar?
PostPosted: Fri Apr 13, 2012 2:00 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 578
Location: germany
My implementation is always crashing on SetGadgetState() inside the thread. I compile threadsave but nothing helped. I'll try the idea to do it in a seperate window which is opened by the thread itself. Maybe this helps...

Thanks anyway,

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
 Post subject: Re: How to do independent progress bar?
PostPosted: Fri Apr 13, 2012 9:18 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2488
Location: New Zealand
don't think there's any nice way to do it threaded on linux
can you thread the loading of the dll instead?
then you could open a new window with a progress bar


Top
 Profile  
 
 Post subject: Re: How to do independent progress bar?
PostPosted: Mon Apr 16, 2012 7:21 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 578
Location: germany
Hi,

is it allowed to utilize a DLL, that was loaded and initialized in the main thread, out from a thread?

Untested code to describe my question:
Code:
ProtoType s_getVersion()
Global s_getVersion.s_getVersion

Procedure Thread(SomeVal.i)
  Protected r.i = s_getVersion() ; <-- is this allowed in a thread?
  If r.i > 0
    Debug PeekS(r.i, -1, #PB_Ascii)
  EndIf
EndProcedure

Libname.s = "SomeLibrary.dll"
; init in main thread
hLib.i = OpenLibrary(#PB_Any, Libname.s)
s_getVersion = GetFunction(hLib, "getVersion")
CreateThread(@Thread(), 0)

Is this allowed or are there also drawbacks on different operating systems?

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
 Post subject: Re: How to do independent progress bar?
PostPosted: Mon Apr 16, 2012 8:31 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 24, 2007 3:15 pm
Posts: 545
Location: Germany
There should be no big difference between the 3 OS, but of
course i have no experience, except on windows. If a DLL is
thread-safe or not is up to the DLL-author.

A single call to one function from a DLL is no problem. After
OpenLibrary(), the functions are available from every thread.

MFG PMV


Top
 Profile  
 
 Post subject: Re: How to do independent progress bar?
PostPosted: Tue Apr 17, 2012 6:21 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 578
Location: germany
Thank you. Upon this, I will try...

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


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:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye