Capturing VMware Events in .NET

I am developing my own .NET application that will be running on a virtual machine (with VMware) and will want to find out if there is a way to receive notifications from VM system events (for example, pause, resume, etc.).

Does anyone know of a convenient way to do this? VMware tools are installed on the virtual machine, does it support the .NET API for connecting events?

EDIT: In particular, I'm interested in when the system just resumed. I suggested that this does not correspond to the "regular" Windows system event (after all, the whole moment of pausing and resuming a virtual machine is that Windows does not know what happened). Am I mistaken? Will this trigger an event?

EDIT 2: I wrote this quick console application to hook up all the system events that I could think of and don't get anything when I pause / resume:

static void Main(string[] args) {

    SystemEvents.DisplaySettingsChanged += (sender, e) => Console.WriteLine("Display settings changed");
    SystemEvents.EventsThreadShutdown += (sender, e) => Console.WriteLine("Events thread shutdown");
    SystemEvents.PowerModeChanged += (sender, e) => Console.WriteLine("Power mode changed");
    SystemEvents.SessionEnding += (sender, e) => Console.WriteLine("Session ending");
    SystemEvents.SessionSwitch += (sender, e) => Console.WriteLine("Session switch");
    SystemEvents.UserPreferenceChanging += (sender, e) => Console.WriteLine("User preference changing");

    Console.ReadLine();
}
+5
source share
2 answers

OK, so I refused to search for a simple .NET binding for this, but if someone else stumbles about it and wants to know how I solved it:

I have a timer in my application that fires regularly (every 10 seconds) and compares the current time with the last. If the time significantly exceeds 10 seconds, I assume that the computer was either asleep or suspended, and updated my application as necessary.

, , , .

+1

All Articles