Killing a non-responsive task

G

Guest

I'm using VBA and automation from Access 2003 on Windows XP Pro. I'm using
the Automation with AutoCAD 2002 to process about 75,000 drawing files.

This works most of the time. However, sometimes AutoCAD loads a drawing
file it cannot handle (corrupt). This stops the processing of further files.

I was thinking to try using a timer in my VBA program to detect if too much
time has elapsed. If the timer goes off I want to kill the AutoCAD task and
restart AutoCAD to process the next drawing. I will also record the problem
in an Access table to later review the bad drawing.

I've tried using acadApp.Application.quit, which sends a quit command to
AutoCAD (acadApp is the AutoCAD object I create when starting AutoCAD).
However this does not seem to work. I need a command the will force AutoCAD
to close, such as End Process in the Windows Task Manager.

Any help is appreciated. Thanks.

Regards,
Leif
 
G

Guest

I don't know about the End Process part, may be something you will have to do
in Windows Script...

However, could you record the file name before processing and update a flag
or delete the entry on success? At least you would be able to see which file
it failed on...

Steve
 
G

Guest

Hi Steve,

Yes, I'm doing that now. I even found some code to kill a task through a
Wndows API call.

The problem I'm facing now is that once an automation call is made my
original Access task, making the call, never gets control back. I set up a
timer, but the timer never fires since control is stuck in my Automation task
(AutoCAD).

Regards,
Leif
 
T

Tony Toews [MVP]

Leif said:
The problem I'm facing now is that once an automation call is made my
original Access task, making the call, never gets control back. I set up a
timer, but the timer never fires since control is stuck in my Automation task
(AutoCAD).

That would make some sense.

Can you run the shell or shellexecute command to process those files?
Then set a timer and every second or so look to see if the process has
completed. Once completed move on to the next. If not completed
after x seconds then kill the task, mark the record in the database
appropriately and continue with the next file.

Probably not because you state you are using automation to do some
processing of the 75,000 drawings. Possibly you could start another
Access MDB (or VB exe) whose only job is to run that automation.

Now as to how many resources a system might consume after starting up
Access 75,000 times I do not know.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
G

Guest

Tony,

Thanks for the help. Yes, you are correct. I'm using automation, so
starting the task via shell will not work for me. I've thinking of doing a
similar thing to what you suggest. Except I was thinking to start a separate
"watch dog" Access task. It would watch the other access tables and if too
long a period elapse since the last entry it would kill AutoCAD, which should
allow the main Access task to resume.

For AutoCAD I'm using automation to open and close drawings, but keeping the
AutoCAD task up. I do check and after processing 1,000 drawings I restart
AutoCAD. This is necessary since AutoCAD has a memory leak and will grow a
bit for each drawing opened/closed.

Regards,
Leif
 
T

Tony Toews [MVP]

Leif said:
Thanks for the help. Yes, you are correct. I'm using automation, so
starting the task via shell will not work for me. I've thinking of doing a
similar thing to what you suggest. Except I was thinking to start a separate
"watch dog" Access task. It would watch the other access tables and if too
long a period elapse since the last entry it would kill AutoCAD, which should
allow the main Access task to resume.

Sure that should work. So long as you can get at whatever data is
required to kill a task via an API call.

As a starting point one of the URLs might, sorta work.
http://vbnet.mvps.org/index.html?code/faq/waitforsingleobject2.htm

Now another approach would be to use the title bar of the currently
running apps. API: Preventing multiple instances of a database
http://www.mvps.org/access/api/api0041.htm While this has a different
purpose you should be able to adapt it for your requirements. Just
figure out the title bar of the AutoCad app.

However as what to use to kill the task I don't know. I'd poke about
a bit on that vbnet.mvps.org site. I didn't see anything at a quick
glance.

If you still can't find anything email me at tony at granite dot ab
dot ca and I'll ask some fellow MVPs, especially Classic VB MVPs. If
there's an answer they'll know.
For AutoCAD I'm using automation to open and close drawings, but keeping the
AutoCAD task up. I do check and after processing 1,000 drawings I restart
AutoCAD. This is necessary since AutoCAD has a memory leak and will grow a
bit for each drawing opened/closed.

Why does that not surprise me? And I don't mean that as a dig at
just AutoCAD but lots of software has memory leaks that show up only
when this kind of thing happens.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top