step887

dllcall hang..

10 posts in this topic

I am calling a custom dll (x86 and x64 specific versions)
Since the x64 dll requires x64 exe, I have "wrapper" that installs the dll/exe for the right OSArch.

The dllcall is correct and works 99% of the time, but sometimes the dllcall will hang due outside influences beyond my control.

Is there a way terminate a dllcall?  I do not see a way within the help file.

The work around I have come up with should work, but does not always work. i suspect that whatever is hanging up the dllcall is preventing the processclose from working.. 

$exe = @WindowsDir & '\test.exe' 
If @OSArch = 'x64' Then
    FileInstall('x64.exe', $exe, 1)
Else
    FileInstall('x86.exe', $exe, 1)
EndIf
Global $gtime = TimerInit()
AdlibRegister('gtimeout', 60000)
RunWait($exe,@windowsdir,@sw_hide)
AdlibUnRegister("gtimeout")

Func gtimeout()
    If TimerDiff($gtime) > 1000 * 60 * 10 Then
        ProcessClose('test.exe')
        $file = FileOpen('log.txt',1)
        FileWriteLine($file, 'Hard Time-out reached.  Exiting...' )
        FileClose($file)
    EndIf
EndFunc   ;==>gtimeout

Right now, it just logs that hard time-out reached over and over.

So is there anyway to kill the dllcall? 

Or ensure I can kill the test.exe process?

Share this post


Link to post
Share on other sites



Hi John,

The Adlib is the wrapper, the dllcall is in the test.exe, so they are separate processes.  The Wrapper is monitoring test.exe and trying to close it after 10 minutes.

The dll is part of third party installation, I suspect that dllcall fails because the installation is broken. But I can't control that.

So if there is not a way to cancel the dllcall, is there a better way to make sure the process ends?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It does not matter If dllcall is in separate process, RunWait is a blocking function so that adlib will not even be called until exe has finished, and exe will not finish untill dllcall has returned.

The problem lies elsewhere.

EDIT:

Although the adlib function may be called however many times 60000 (1 minute) goes into however long it takes exe to finish.

 

The script is the same as this...

AdlibRegister("_func")

MsgBox(0,0, "Main body")

AdlibUnRegister("_func")

Func _Func()
    MsgBox(0,0,"_Func")
EndFunc

 

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

No I disagree, create test.exe:

MsgBox(0,@ScriptName,"do not click")

Then use this to run the test.exe

Global $gtime = TimerInit()
AdlibRegister('gtimeout')
RunWait('test.exe',@ScriptDir)
AdlibUnRegister("gtimeout")
Func gtimeout()
    If TimerDiff($gtime) > 1000 * 15 Then
        ProcessClose('test.exe')
        $file = FileOpen('log.txt',1)
        FileWriteLine($file, 'Hard Time-out reached.  Exiting...' )
        FileClose($file)
    EndIf
EndFunc   ;==>gtimeout

I am using "wrapper" process to monitor a subprocess, but my subprocess is not responding to processclose like the above example.

Share this post


Link to post
Share on other sites

Well bruise my hole with a welly, I thought RunWait() was blocking function, appears not.

My apologies.

Still, I'd think about why the dllcall is hanging its process, since it cannot be stopped once it is started.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

JohnOne,

Quote

I thought RunWait() was blocking function

It is. Run this:

AdlibRegister("_Func", 1000)
RunWait("notepad.exe")
ConsoleWrite("Arrived here at " & @SEC & "!" & @CRLF)

Func _Func()
    ConsoleWrite("Adlib at " & @SEC & @CRLF)
EndFunc

The Adlib fires every second as that is using a timer from outside the script itself - the final ConsoleWrite waits until you close the Notepad window.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Handy to know you can continue to perform some tasks while runwait is ... running, and... waiting.

So what blocking funcyions can adlib work around I wonder, cause the same behaviour is not the case with msgbox.

@step887 does task manager end the process?


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

JohnOne,

I imagine the difference is that RunWait is waiting for an external program to terminate, whereas MsgBox is internal to the script itself - but I am not at all sure of that.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@JohnOne Yes Task manager is able to kill the process. I guess I could try taskkill.. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now