MEDriver Sample: Demonstrates COM Eventing in the .NET Framework
The MEDriver sample illustrates the use of COM events (fired from an unmanaged COM server) through a .NET Framework wrapper, automatically generated from the COM server's type library.
MEDriver is implemented as a Windows Forms application. It uses the ATL sample CONNECT as the COM server, and it wraps and uses its interface
IRandom and source interface
IRandomEvent_FireEventHandler as if it was a .NET Framework event. The application creates multiple sinks to the
Fire event of class
CoRandom and controls the threads that the server creates.
Building and Running the Sample
To build and run MEDriver using Visual Studio
- In the Visual Studio IDE, load the solution file MEDriver.sln.
- In Solution Explorer, right-click the MEDriver solution.
- On the shortcut menu, click Build Solution.
- On the Debug menu, click Start.
When you run MEDriver.exe, click the Start button at least once, and then click the Advise button several times. Each click of the Advise button adds a sink to the Fire event, which makes the display wider. If you do not click the Advise button, you will not see any activity in the display.
This sample demonstrates the following keywords:
Control::CreateGraphics; Control::ClientRectangle; Graphics::DrawLine; Color::FromArgb; Mutex::WaitOne; Mutex::ReleaseMutex; Hashtable::Item; Application::Run; Button::Location; Button::Size; Button::Text; ControlCollection::AddRange