Timeout

Timeout

Anonymous
Not applicable
613 Views
12 Replies
Message 1 of 13

Timeout

Anonymous
Not applicable
I am working on a batch program to process 1000 + files. I started out as
a addin, but it kept hanging on me. I tried making Inventor invisible, and
added delay loops after opening and closing etc, but it didn't fix it. So I
finally switched it to a exe but I still have the same problem. I have now
made it so it makes a log file, and this last time it hung while opening a
IDW.

So my question is, how do you initiate something like loading a file, but if
it hasn't loaded within some set timeframe like 60 seconds, then to abort
and continue with the rest of the code?

--
___________________
Kent Keller
www.kwikmcad.com
0 Likes
614 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable
I have never done anything like that, but...

Sub DoWeMakeItInTime()

Dim bComplete As Boolean
Dim iCounter As Long
Dim i As Long
Dim StartTime As Date
Dim ExpiredTime As Date
Dim Duration As Long
Dim TimeLeft As Date

i = 0
iCounter = 5000000 'Increase/Decrease this value!!!
bComplete = False
StartTime = Time
Duration = 10 'seconds
ExpiredTime = DateAdd("s", Duration, StartTime)

DoEvents

Do Until bComplete = True
If Time > ExpiredTime Then
MsgBox "This takes too long!"
Exit Do
End If

i = i + 1

If i = iCounter Then
bComplete = True
End If

If bComplete = True Then
TimeLeft = ExpiredTime - Time
MsgBox "Yeah, we made it in time! Time left = " & TimeLeft
End If
Loop

End Sub


--
T. Ham
CAD Automation & Systems Administrator
CDS Engineering BV

HP xw4300 Workstation
Dual Pentium XEON 3.6 Ghz
4 GB SDRAM
NVIDIA QUADRO FX 3450/4000 SDI (Driver = 8.4.2.6)
250 GB SEAGATE SATA Hard Disc
3Com Gigabit NIC

Windows XP Professional SP2
Autodesk Inventor Series 10 SP3a
--
0 Likes
Message 3 of 13

Anonymous
Not applicable
Thanks Teun and Neil

I have looked at adding a timer to the form, and may end up doing, it if it
becomes absolutely necessary.

--
___________________
Kent Keller
www.kwikmcad.com


"Teun Ham (IV10 SP3)" wrote in
message news:5521072@discussion.autodesk.com...
I have never done anything like that, but...

Sub DoWeMakeItInTime()
0 Likes
Message 4 of 13

Anonymous
Not applicable
I am back to trying to figure out a way to timeout a locked up program. But
it seems to me the only way it is going to work is if the program is multi
threaded. Am I wrong?

One time I will lock up printing to PDF, and the next time it will lock up
closing a drawing. In both those cases I am using On Error Resume next and
error control, but my guess is that my program is waiting for the PDF
Printer to finish, or for the close document command to complete and for
some reason they are not.

Am I missing something.


--
___________________
Kent Keller
www.kwikmcad.com
0 Likes
Message 5 of 13

Anonymous
Not applicable
Timer controls, or the use of Windows or .NET (of course you are using
VB.NET, aren't you ) timer classes are by default run on a sepatate
thread. The timer 'expired' event should not be affected by conditions in
your main program thread. Of course, gaining control of that main thread
might be an issue. Constructing your code that the timer event can 'escape'
from an apparemt lock up is the tricky bit. I haven't constructed anything
with this particular functionality so sorry I can't help more. Perhaps
Brian, Sanjay, or others have some more, or better ideas.

Neil


"Kent Keller" wrote in message
news:5523703@discussion.autodesk.com...
I am back to trying to figure out a way to timeout a locked up program. But
it seems to me the only way it is going to work is if the program is multi
threaded. Am I wrong?

One time I will lock up printing to PDF, and the next time it will lock up
closing a drawing. In both those cases I am using On Error Resume next and
error control, but my guess is that my program is waiting for the PDF
Printer to finish, or for the close document command to complete and for
some reason they are not.

Am I missing something.


--
___________________
Kent Keller
www.kwikmcad.com
0 Likes
Message 6 of 13

Anonymous
Not applicable
Someone at Autodesk should know...

The TaskScheduler does the same thing: openening, updating and saving
Inventor files. If something is wrong, the TaskScheduler will close the
offending part/assembly/drawing and tries to reopen it a second time. If
that fails, it will skip the file and continues with the next one.

So it should be possible...

--
T. Ham
CAD Automation & Systems Administrator
CDS Engineering BV

HP xw4300 Workstation
Dual Pentium XEON 3.6 Ghz
4 GB SDRAM
NVIDIA QUADRO FX 3450/4000 SDI (Driver = 8.4.2.6)
250 GB SEAGATE SATA Hard Disc
3Com Gigabit NIC

Windows XP Professional SP2
Autodesk Inventor Series 10 SP3a
--
0 Likes
Message 7 of 13

Anonymous
Not applicable
I agree about Task Scheduler's ability to do this. My program is very
similar to task manager, except it is for one specific task. I think
anytime you process a large amount of files the possibilty of one of the
calls failing to complete is pretty high.

What would be really cool is if when you did things like open or close a
document, start or close Inventor etc, there was a optional time variable
you could specify, that where if it hadn't finished in less time than the
variable, then it would throw a error and move on.

--

Kent Keller
"Teun Ham (IV10 SP3)" wrote in
message news:5523939@discussion.autodesk.com...
Someone at Autodesk should know...

The TaskScheduler does the same thing: openening, updating and saving
Inventor files. If something is wrong, the TaskScheduler will close the
offending part/assembly/drawing and tries to reopen it a second time. If
that fails, it will skip the file and continues with the next one.

So it should be possible...

--
T. Ham
CAD Automation & Systems Administrator
CDS Engineering BV

HP xw4300 Workstation
Dual Pentium XEON 3.6 Ghz
4 GB SDRAM
NVIDIA QUADRO FX 3450/4000 SDI (Driver = 8.4.2.6)
250 GB SEAGATE SATA Hard Disc
3Com Gigabit NIC

Windows XP Professional SP2
Autodesk Inventor Series 10 SP3a
--
0 Likes
Message 8 of 13

Anonymous
Not applicable
Neil

Not using .NET. I haven't really warmed up to it yet. I may be to old to
learn new tricks. ;~)

So are you saying the timer control in VB6 runs on a separate thread?

As you say though, if Inventor or the printer driver are locked up, I am not
sure there is much I could do to shut them down.

--
___________________
Kent Keller
www.kwikmcad.com


"Neil Munro" wrote in message
news:5523752@discussion.autodesk.com...
Timer controls, or the use of Windows or .NET (of course you are using
VB.NET, aren't you ) timer classes are by default run on a sepatate
thread. The timer 'expired' event should not be affected by conditions in
your main program thread. Of course, gaining control of that main thread
might be an issue. Constructing your code that the timer event can 'escape'
from an apparemt lock up is the tricky bit. I haven't constructed anything
with this particular functionality so sorry I can't help more. Perhaps
Brian, Sanjay, or others have some more, or better ideas.

Neil
--
___________________
Kent Keller
www.kwikmcad.com
0 Likes
Message 9 of 13

Anonymous
Not applicable
Maybe you can use the Windows API to terminate the "Inventor.exe" if a
process is not responding anymore (mimick the behaviour of the Windows Task
Manager)?

--
T. Ham
CAD Automation & Systems Administrator
CDS Engineering BV

HP xw4300 Workstation
Dual Pentium XEON 3.6 Ghz
4 GB SDRAM
NVIDIA QUADRO FX 3450/4000 SDI (Driver = 8.4.2.6)
250 GB SEAGATE SATA Hard Disc
3Com Gigabit NIC

Windows XP Professional SP2
Autodesk Inventor Series 10 SP3a
--
0 Likes
Message 10 of 13

Anonymous
Not applicable
Sorry Kent, I didn't realize that the VB6 timer control actually runs on the
same thread as the application. .NET exposes a number of asynchronous thread
classes, you would probably need use Win32 timer functions to build a
reliable time-out mechanism.

Neil

"Kent Keller" wrote in message
news:5524397@discussion.autodesk.com...
Neil

Not using .NET. I haven't really warmed up to it yet. I may be to old to
learn new tricks. ;~)

So are you saying the timer control in VB6 runs on a separate thread?

As you say though, if Inventor or the printer driver are locked up, I am not
sure there is much I could do to shut them down.

--
___________________
Kent Keller
www.kwikmcad.com


"Neil Munro" wrote in message
news:5523752@discussion.autodesk.com...
Timer controls, or the use of Windows or .NET (of course you are using
VB.NET, aren't you ) timer classes are by default run on a sepatate
thread. The timer 'expired' event should not be affected by conditions in
your main program thread. Of course, gaining control of that main thread
might be an issue. Constructing your code that the timer event can 'escape'
from an apparemt lock up is the tricky bit. I haven't constructed anything
with this particular functionality so sorry I can't help more. Perhaps
Brian, Sanjay, or others have some more, or better ideas.

Neil
--
___________________
Kent Keller
www.kwikmcad.com
0 Likes
Message 11 of 13

Anonymous
Not applicable
Thanks Neil

I tried playing with the timer in .Net and it doesn't seem to work any
different to me. What am I missing.

The following code is a form with one button and two labels. The timer
doesn't fire until the "Do Until" loop is done (I know a doevents would
allow it to exit, but that wouldn't mimic a locked up Inventor)



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Timer1.Interval = 6000

Timer1.Enabled = True

Call loopme()

End Sub

Private Sub loopme()

Dim Starttime As Single

Dim QuitTime As Single

QuitTime = 10

Starttime = Microsoft.VisualBasic.DateAndTime.Timer

Do Until Microsoft.VisualBasic.DateAndTime.Timer > Starttime + QuitTime

Label1.Text = Microsoft.VisualBasic.DateAndTime.Timer

Me.Refresh()

Loop

End Sub



Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Timer1.Tick

Label2.Text = "Fired"

Me.Refresh()

' Stop

End Sub

End Class



--
___________________
Kent Keller
www.kwikmcad.com


"Neil Munro" wrote in message
news:5524510@discussion.autodesk.com...
Sorry Kent, I didn't realize that the VB6 timer control actually runs on the
same thread as the application. .NET exposes a number of asynchronous thread
classes, you would probably need use Win32 timer functions to build a
reliable time-out mechanism.

Neil
0 Likes
Message 12 of 13

Anonymous
Not applicable
You are using the VB6 timer here. The .NET framework has two or three Timer
classes, some of which enable objects on separate threads. I think the
native .NET timer control also operates asynchronously (is just a wrapper
around the Timer classes). You will need to get a bit familiar with
delegates to work with asynchronous objects created from the Timer classes.

Sorry I can't be more specific (time(r) issues).

Neil



"Kent Keller" wrote in message
news:5524823@discussion.autodesk.com...
Thanks Neil

I tried playing with the timer in .Net and it doesn't seem to work any
different to me. What am I missing.

The following code is a form with one button and two labels. The timer
doesn't fire until the "Do Until" loop is done (I know a doevents would
allow it to exit, but that wouldn't mimic a locked up Inventor)



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Timer1.Interval = 6000

Timer1.Enabled = True

Call loopme()

End Sub

Private Sub loopme()

Dim Starttime As Single

Dim QuitTime As Single

QuitTime = 10

Starttime = Microsoft.VisualBasic.DateAndTime.Timer

Do Until Microsoft.VisualBasic.DateAndTime.Timer > Starttime + QuitTime

Label1.Text = Microsoft.VisualBasic.DateAndTime.Timer

Me.Refresh()

Loop

End Sub



Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Timer1.Tick

Label2.Text = "Fired"

Me.Refresh()

' Stop

End Sub

End Class



--
___________________
Kent Keller
www.kwikmcad.com


"Neil Munro" wrote in message
news:5524510@discussion.autodesk.com...
Sorry Kent, I didn't realize that the VB6 timer control actually runs on the
same thread as the application. .NET exposes a number of asynchronous thread
classes, you would probably need use Win32 timer functions to build a
reliable time-out mechanism.

Neil
0 Likes
Message 13 of 13

Anonymous
Not applicable
No Problem Neil. I appreciate all your help.

--
___________________
Kent Keller
www.kwikmcad.com


"Neil Munro" wrote in message

Sorry I can't be more specific (time(r) issues).

Neil
0 Likes