Receiving Virtual Server events from a managed program

Receiving Virtual Server events from a managed program

  • Comments 2

Last week I talked about how to receive Virtual Server events from a VBScript - this week I am going to talk about doing this from a managed application.  To do this you need to:

  1. Setup the managed application appropriately to talk to the Virtual Server COM interfaces (details here: http://blogs.msdn.com/virtual_pc_guy/search.aspx?q=typer&p=1)

  2. Declare your Virtual Server COM object 'WithEvents' as follows:


    Private WithEvents virtualServer As VMVirtualServer = Nothing

    instead of:

    Private virtualServer As VMVirtualServer = Nothing

  3. Create a subroutine to catch the event:

    Public Sub virtualServer_EventLogged(ByVal logMessageID As Integer) Handles virtualServer.OnEventLogged

         'Do something with the event
         msgbox(CStr(logMessageID))

    End Sub

There - really quite simple.

Cheers,
Ben

Leave a Comment
  • Please add 5 and 3 and type the answer here:
  • Post
  • Hi, Ben,
    Very nice series on Event detection and handling on VS.

    We are trying to detect when a legacy(and unstable) application crash the virtual machine. Is such event a vmVirtualMachineEvent_TripleFault or a
    vmVirtualMachineEvent_HeartbeatStopped?

    What are the difference between these two events in terms of impact on host OS?

    Ying
  • Hi Ying,

    You should be looking at 'HeartbeatStopped' event - as that will fire whenever the virtual machine crashes. TripleFault is a specific kind of crash - and will still trigger a 'HeartbeatStopped' event.

    Cheers,
    Ben
Page 1 of 1 (2 items)