How do I pass arguments to a PowerModeChangedEventHandler (managed VC)?

I want to do some stuff whenever the power mode changes, including writing some stuff to a log. Here's some snippets from my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
void SystemEvents_PowerModeChanged(Object^ sender, PowerModeChangedEventArgs^ e)
{
	switch(e->Mode)
	{
		case PowerModes::Resume:
		Console::WriteLine("System resumed")
		// How do I pass in StreamWriter oWrite as a local variable?
		// oWrite->WriteLine("System resumed")
	}
}

int main(array<System::String ^> ^args)
{
	try
	{
		StreamWriter^ oWrite = gcnew StreamWriter("out.txt");
		oWrite->AutoFlush = true

		//launch a bunch of threads via ParameterizedThreadStart that aren't related to this specific problem but will keep the program from ending before I want it to
		...

		SystemEvents::PowerModeChanged += gcnew PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
	}
	catch(System::Exception ^ e)
	{
		Console::WriteLine(e->Message);
		return 1;
	}
	return 0;
}


What do I need to do to pass parameters, such as oWrite, to the PowerModeChangedEventHandler function? PowerModeChangedEventArgs seems to have "mode" as its only exposed member.
Topic archived. No new replies allowed.