While loop takes CPU resources
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
While loop takes CPU resources
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
Jim Claypool
Guest





Posted: Fri Jan 07, 2005 2:35 am    Post subject: Re: While loop takes CPU resources Reply with quote

I tried it and I can go do anything I want.
Map 2005 3D WinXP-Home Sp2


"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:41dd8da4_1@newsprd01...
Quote:
Sorry, no clue about why that's happening.

Perhaps someone else can try it, and see if
they get the same thing. I can't reproduce
it on WinXP with A2K5.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com

"Eric Schneider" <eschneider@spamfree.jensenprecast.com> wrote in message
news:41dd8b31$1_3@newsprd01...
Command: (dos_processes)
("smss.exe" "winlogon.exe" "services.exe" "lsass.exe" "svchost.exe"
"spoolsv.exe" "msdtc.exe" "ActionAgent.exe" "DellDmi.exe" "EventAgt.exe"
"DLT.exe" "svchost.exe" "Iap.exe" "mdm.exe" "nvsvc32.exe" "regsvc.exe"
"MSTask.exe" "Win32sl.exe" "WinMgmt.exe" "svchost.exe" "inetinfo.exe"
"svchost.exe" "Explorer.EXE" "jusched.exe" "PwsTray.exe" "TeaTimer.exe"
"ctfmon.exe" "Printkey2000.exe" "OUTLOOK.EXE" "msimn.exe" "POINT32.EXE"
"acad.exe" "AdskCleanup.0001" "AdskScSrv.exe" "WSCommCntr1.exe"
"wisptis.exe"
"pageant.exe" "putty.exe" "putty.exe" "winscp368.exe" "AcroTray.exe"
"putty.exe" "IEXPLORE.EXE" "IEXPLORE.EXE" "notepad.exe" "IEXPLORE.EXE")

"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:41dd8467$1_2@newsprd01...
Is there any other applications open? If so what are they?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com

"Eric Schneider" <eschneider@spamfree.jensenprecast.com> wrote in
message
news:41dd80f2$1_3@newsprd01...
W2kpro with all the latest, ACAD2005 with all the latest.

"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:41dd7db8$1_2@newsprd01...
Eric - Doesn't happen here (WinXP SP2).

Per chance, are you using some bozo (e.g. Win9x)
operating system?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com

"Eric Schneider" <eschneider@spamfree.jensenprecast.com> wrote in
message
news:41dd7b56$1_1@newsprd01...
I'm not doing anything within the (slightly modified, see below)
C:TEST
function either, just trying it out before I implement it. While
in
the
while loop (while the while, heh heh), if I switch focus to any
other
app,
like notepad, Outlook or Explorer, I don't have enough time to do
anything
before it looses focus to ACAD.

Create a file named C:\b.txt, start the C:TEST function and try to
rename it
to C:\a.txt.

(defun C:TEST (/ acad ws)
(setq acad (vlax-get-acad-object))

;; This will prevent the user from
;; switching to a different document.
;; (improper use of this function can
;; be dangerous):

(DisableDocumentActivation)
(setq ws (vla-get-windowstate acad))
(vla-put-windowstate acad 2)

;; This code is wrapped in an exception handler
;; to ensure the call to EnableDocumentActivation
;; that follows it, is reached. If it is not, there will
;; be problems:

(vl-catch-all-apply
'(lambda ()
(while (not (findfile "C:/a.txt"));give it something to
test

;; Calling this function forces AutoCAD
;; to process its message queue:

(DoEvents)

;; Do whatever you need here
)
)
)

(vla-put-windowstate acad ws)
(EnableDocumentActivation) ;; Make sure you do this!!!

)

"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:41dd7772_1@newsprd01...
Eric - Not sure what you mean by 'grabbing focus'.

Is AutoCAD in the foreground, or is it bringing itself
into the foreground and taking focus from another app?

If so, what app?

Doesn't happen here using the sample test function I
posted (which does nothing in the (while) loop).

Perhaps there's something in your loop that's
doing it?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com

"Eric Schneider" <eschneider@spamfree.jensenprecast.com> wrote in
message
news:41dd6f56$1_1@newsprd01...
Nice functions Tony. Is there a way to keep ACAD from grabbing
focus
every
second or so? It even grabs focus when (vla-put-windowstate
(vlax-get-acad-object) 2).

Regards,
Eric S

"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in
message
news:41dd5abe_1@newsprd01...
Attached to this is a small ObjectARX library called
DoEvents.ARX.

Load it using (arxload "DoEvents.arx"). It will
define a LISP function called (DoEvents), which
is functionally equivalent to VBA's DoEvents() function.

Call the DoEvents function from the body of your
(while) loop and it should sove your problem.

There's a few caveats to this, mainly that it will
allow the user to switch documents, which is a no-no
when it comes to LISP, because that will suspend your
application until the document it runs in is made
active again. To address this, there are two other
functions to enable/disable document activation:

(EnableDocumentActivation)
(DisableDocumentActivation)

I suggest you call the latter before you start the
(while) loop in which you call DoEvents, and make
sure you call the former before your LISP calls any
API that polls for input.

So, you would basically have something like this:

(arxload "DoEvents.arx")

(defun C:TEST ()

;; This will prevent the user from
;; switching to a different document.
;; (improper use of this function can
;; be dangerous):

(DisableDocumentActivation)

;; This code is wrapped in an exception handler
;; to ensure the call to EnableDocumentActivation
;; that follows it, is reached. If it is not, there will
;; be problems:

(vl-catch-all-apply
'(lambda ()
(while <condition

;; Calling this function forces AutoCAD
;; to process its message queue:

(DoEvents)

;; Do whatever you need here
)
)
)

(EnableDocumentActivation) ;; Make sure you do this!!!

)


PS: This is for AutoCAD 2004/2005 only

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com

"Tim Skene" <tim.skene@spamfree.multicimdotcom> wrote in
message
news:41dccd67_3@newsprd01...
Try:

(while <condition
(command "._DELAY" 1000) ; change millisecs to suit
)

Makes no difference. Whether I put a long, short or no delay
in
the
loop, it
seems to be the overhead of the while loop that causes the
problem.

--
Tim Skene






















Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB