I feel like this is really basic, but I'm having trouble with this issue. I'm using a Process
object and subscribing to a DataReceivedEventHandler
. This event handler then delegates to another method, in this case "DoSomething", and the signature for the arguments is (Object sender, DataReceivedEventArgs args). What I need to do, is extend something, or provide something that will pass in additional information. Here is my current code:
// an object of some type
MyCustomObject obj = new MyCustomObject();
// set up obj and Process
process.OutputDataReceived += new DataReceivedEventHandler(DoSomething);
public void DoSomething(Object sender, DataReceivedArgs args)
{
// do some stuff, however, I need the "obj" object passed in for work
}
I feel like this is really trivial, but not sure how to proceed. I've read about subclassing the "EventArgs," but not sure how that will help, or how to even change the signature of "DoSomething" to accept a DataReceivedArgsExtended
parameter, since the DataReceivedEventHandler is expecting a method with a DataReceivedArgs