How to suspend an application for any time

This is a discussion on How to suspend an application for any time within the Clipper forums in Programming Languages category; Hi all! How can I stopp the execution of an Application until a certain event occurs? e.g. Method pshStart Class Xyz (data or dialog window) Do While TRUE DoAnythink() If !WaitUntilOK() EXIT EndIf If !Continue() EXIT EndIf EndDo Function WaitUntilOK() Local lRet As Logic DO WHILE _lWait // e.g. global variable IF PeekMessage( @msg, 0, 0, 0, PM_REMOVE) TranslateMessage (@msg) DispatchMessage (@msg) ENDIF ENDDO lRet := CheckSomething() Return lRet This Function causes a processor load of 100 %. Is there a better way to realize this function? Regards Gunter...

Go Back   Application Development Forum > Programming Languages > Clipper

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-21-2008, 09:35 AM
Gunter
Guest
 
Default How to suspend an application for any time

Hi all!
How can I stopp the execution of an Application until a certain event
occurs?
e.g.
Method pshStart Class Xyz (data or dialog window)
Do While TRUE
DoAnythink()

If !WaitUntilOK()
EXIT
EndIf

If !Continue()
EXIT
EndIf

EndDo

Function WaitUntilOK()
Local lRet As Logic
DO WHILE _lWait // e.g. global variable
IF PeekMessage( @msg, 0, 0, 0, PM_REMOVE)
TranslateMessage (@msg)
DispatchMessage (@msg)
ENDIF
ENDDO
lRet := CheckSomething()
Return lRet

This Function causes a processor load of 100 %.
Is there a better way to realize this function?

Regards
Gunter
Reply With Quote
  #2  
Old 08-21-2008, 10:07 AM
D.J.W. van Kooten
Guest
 
Default Re: How to suspend an application for any time

On Thu, 21 Aug 2008 06:35:39 -0700 (PDT), Gunter
<g.huebner@dsh-anklam.de> wrote:

Hello Gunter,

>Hi all!
>How can I stopp the execution of an Application until a certain event
>occurs?


You can set a timer from the dialog you want the waiting to start
from:

SELF:RegisterTimer( 4, FALSE )
SetTimer(SELF:Handle(), 4, 60000, NULL_PTR) // every minute = 60.000
ms

In the windows' dispatch you add:

IF (uMsg == WM_TIMER) .AND. (oEvt:wParam == 4) // Timer event 4
....IF PEEKMESSAGE...
ENDIF

Don't forget KillTimer(SELF:Handle(), 4) in the window's close

Dick van Kooten
Reply With Quote
  #3  
Old 08-21-2008, 07:38 PM
Stephen Quinn
Guest
 
Default Re: How to suspend an application for any time

Gunter

Is the *event* our waiting on an external app. or an internal function of
your app??

If external app. look at CreateProcess() in the Win32 API.

CYA
Steve


Reply With Quote
  #4  
Old 08-22-2008, 02:41 AM
martti.toivonen@utu.fi
Guest
 
Default Re: How to suspend an application for any time

A similar problem: is there a way to make my app wait until a report
has been printed out to a pdf by the Pdfcreator? At the moment I have
a do while -loop checking for the existence of the resulting pdf in
the given folder but I would prefer a more fluent solution. Any hints?
mot
Reply With Quote
  #5  
Old 08-22-2008, 03:33 AM
Stephen Quinn
Guest
 
Default Re: How to suspend an application for any time

Marti

>A similar problem: is there a way to make my app wait until a report
> has been printed out to a pdf by the Pdfcreator?

Hard to do if the print spooler is used on the machine as that's the
interface for print jobs.
I suppose you could try querying the printer via API.

If you write your PDF directly to disk it should only take a couple of
seconds to ceate the PDF file, in our tests we created ~2000 PDFs (mostly
single page statements) in less than 5 minutes.

We use a class wrapper I wrote around RP2 and MD_PDF to create them
- I should say that ALL our reports are hand coded (i.e. not using the
..RPTs).

CYA
Steve


Reply With Quote
  #6  
Old 08-22-2008, 03:41 AM
D.J.W. van Kooten
Guest
 
Default Re: How to suspend an application for any time

On Thu, 21 Aug 2008 23:41:45 -0700 (PDT), martti.toivonen@utu.fi
wrote:

Hello Martti,

>A similar problem: is there a way to make my app wait until a report
>has been printed out to a pdf by the Pdfcreator? At the moment I have
>a do while -loop checking for the existence of the resulting pdf in
>the given folder but I would prefer a more fluent solution. Any hints?


I do the same, like this:

FOR ni:=1 UPTO 11 // Then we have to wait to make the next PDF until
the last one is ready
IF File(cPDFPath+cPDFName) // Do we see the created PDF?
lok:=TRUE // Done!
EXIT // exit for..next, we are ready
ENDIF
WaitTime(2) // Wait 2 seconds max 10 x

I hope that the next ReportPro will solve PDF printing 100% so we
won't need PDFCreator anymore.

Dick
Reply With Quote
  #7  
Old 08-22-2008, 05:52 AM
Gunter
Guest
 
Default Re: How to suspend an application for any time

Hi,
the DoAnythink()-function is in fact a print modul that owns a
callback-function. This callback-function sends messages if
the job is done/sent to the printspooler (not to the printer) or is
broken.
This messages I can receive und and responde accordingly.
But for this time the Application have to wait.
Now I let the callback-function set a global variable (_lWait),
the WaitUntilOK()-function queries it and stopps the App
until this variable ist set by the callback.
It is ok so, but it causes a processor load of 100 %
so that other processe are constrained.
Not a good solution...

Gunter

Reply With Quote
  #8  
Old 08-22-2008, 12:05 PM
Norbert Kolb
Guest
 
Default Re: How to suspend an application for any time

Hi Gunter!

Insert
Sleep(100)
in your loop and try again.

Norbert


"Gunter" <g.huebner@dsh-anklam.de> schrieb im Newsbeitrag
news:030950ab-7d1e-4cf8-8675-c35d9331aa8a@c65g2000hsa.googlegroups.com...
> Hi,
> the DoAnythink()-function is in fact a print modul that owns a
> callback-function. This callback-function sends messages if
> the job is done/sent to the printspooler (not to the printer) or is
> broken.
> This messages I can receive und and responde accordingly.
> But for this time the Application have to wait.
> Now I let the callback-function set a global variable (_lWait),
> the WaitUntilOK()-function queries it and stopps the App
> until this variable ist set by the callback.
> It is ok so, but it causes a processor load of 100 %
> so that other processe are constrained.
> Not a good solution...
>
> Gunter
>



Reply With Quote
  #9  
Old 08-23-2008, 07:32 AM
Alessandro Antonangeli
Guest
 
Default Re: How to suspend an application for any time

Just put:
Sleep(40)
GetAppObject():Exec(EXECWHILEEVENT)
inside the loop
--
Ciao
Alessandro
"Gunter" <g.huebner@dsh-anklam.de> ha scritto nel messaggio
news:45502828-ec57-4616-9d0b-7288b7004140@s50g2000hsb.googlegroups.com...
> Hi all!
> How can I stopp the execution of an Application until a certain event
> occurs?
> e.g.
> Method pshStart Class Xyz (data or dialog window)
> Do While TRUE
> DoAnythink()
>
> If !WaitUntilOK()
> EXIT
> EndIf
>
> If !Continue()
> EXIT
> EndIf
>
> EndDo
>
> Function WaitUntilOK()
> Local lRet As Logic
> DO WHILE _lWait // e.g. global variable
> IF PeekMessage( @msg, 0, 0, 0, PM_REMOVE)
> TranslateMessage (@msg)
> DispatchMessage (@msg)
> ENDIF
> ENDDO
> lRet := CheckSomething()
> Return lRet
>
> This Function causes a processor load of 100 %.
> Is there a better way to realize this function?
>
> Regards
> Gunter



Reply With Quote
  #10  
Old 08-23-2008, 08:01 AM
Alessandro
Guest
 
Default Re: How to suspend an application for any time

You could also look at this post of Fabrice Foray and the relative API
http://groups.google.it/group/comp.l...5bc64443239148
--
Ciao
Alessandro

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 11:27 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.