No announcement yet.

VB Threaded Events

  • Filter
  • Time
  • Show
Clear All
new posts

  • VB Threaded Events

    Hey all,

    I am trying to figure this out. VB is not reentrant, you create a thread in vb with COM and somewhere along the line it will crash. To bypass this what I need to do is create a window and instead of firing off the event a message is posted to the window. The window is then charged with firing the event. The RAISEEVENT statement, what is used to fire off the event, can not be called from anywhere other than an object procedure. Has anyone had a chance to do something like this? and if so, how did you do it?

    Sr. Software Development Engineer and Sr. Information Security Analyst,
    CEH, Digital Forensic Examiner

  • #2
    Yes, I did that. You can see it at
    The DLL is written in PB 7.02 and there is a VB6 ActiveX wrapper doing exactly the same that you said, posting messages to a textbox instead of having a callback function directly in VB. Yet, the events are fired as 'normal'.

    Peter Redei


    • #3
      i was hoping that I could get an example for pb 9 and its native handling of COM. Thanks
      Sr. Software Development Engineer and Sr. Information Security Analyst,
      CEH, Digital Forensic Examiner


      • #4
        Hi Thomas,
        I am not sure it can be done, but I am working on it.

        Being all too aware of VB not liking multi-threaded apps, and the concept that years ago it hit me that most of my problems with serial ports was the MSCOMM32.OCX I moved on to PB for the needed speed and control that was needed, but one drawback, I needed to create a thread to listen to the port so that I was not polling to see if something was there.

        It may not have taken 21 virgins, and 7 sacrificial lambs to achieve the task, but it did take great care to ensure any threads created were destroyed, and memory freed etc.... to keep VB from crashing.

        Hopefully now with the advent of PB9 and producing COM I will be able to solve a "feature" of VB that has always bugged me, but solvable via PB???
        (AKA: Multiple ports, without Multiple copies of the same code (just renamed functions with a 2 or 3 or 4 or more, tagged onto the end of the function, and multiple copies of the same PB DLL renamed as the same style) and thus doubling, tripling, quadrupling, etc the over all size of the code???)

        Hopefully if I can tie up a few confused thoughts I can work events into the equation
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "