Results 1 to 9 of 9

Thread: native-code hangs after msg handler

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    6

    native-code hangs after msg handler

    Hi:

    I'm using VB Enterprise on W2K. I have a simple form app with a button handler. When I've compiled the code to p-code it works just fine, but when I compile to native code it hangs when it exits the message handler. When I go into Task Manager, it indicates my app is using 97-99% of the CPU.

    I get the same results on XP.

    Thanxs for your feedback,

    redcpu

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    6
    No. I've tried "Fast Code" and "No Optimizations" on the Compile tab and both get the same results.

    I suspect there's an infinite loop but it appears that infinite loop isn't in my code since the very last line of the msg handler is

    MsgBox(.....)

    which executes and then the hang occurs.

    redcpu
    Last edited by redcpu4ghz; May 19th, 2003 at 12:16 PM.

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    6
    I also wonder if I have some stack corruption problem . I wish I could "debug" the native code .exe using a disassembler like VC++.
    Last edited by redcpu4ghz; May 19th, 2003 at 12:19 PM.

  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Can you give us an idea of what the message handler is doing (a code snippet maybe)

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    6
    Private Sub Button_Click()

    Dim buffer(8) As Byte
    Dim retval As Long
    Dim rc As Long

    retval = SendCommand(2,6,0, buffer(), 6, 1, 8, 0)

    If retval <> 1 Then
    Msg.Text = Msg.Text & "Command failed ... exiting." & vbCrLf
    End If

    rc = MsgBox("GettingOuttaHere", vbOKOnly)

    End Sub

    The prototype for SendCommand is:

    Declare Function SendCommand Lib "blah.dll" (ByVal firstparam As Long, ByVal secondparam As Long, ByVal thirdparam As Long, buffer() As Byte, ByVal length As Long, ByVal sixparam As Long, ByVal datalength As Long, ByVal eightparam As Long) As Integer

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    6
    Forgot to mention - the function SendCommand has the proper VB linkage, namely _stdcall (as opposed to cdecl linkage).

    redcpu

  8. #8
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Have you identified that it's the code in the Button Click event that's causing the application to hang?

    If not, try commenting out code in the event until the behavior stops.

  9. #9

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    6
    I've commented out the call to SendCommand and the hang doesn't occur. What's got me is why, when I compile to p-code, it all works?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width