c# - Parameter in event handler is not hitting while debugging -
i have eventhandler code below :
viewer.localreport.subreportprocessing += new microsoft.reporting.webforms.subreportprocessingeventhandler(localreport_subreportprocessing);
and method parameter event handler above :
private static void localreport_subreportprocessing(object sender, subreportprocessingeventargs e) { datetime movementdate = convert.todatetime(e.parameters[0].values[0]); tourtransactionscontroller controller = new tourtransactionscontroller(); var movement = controller.movements(); list<movement> movementlist = new list<movement>(); movementlist.add(new movement { destination = "test", movementdescription = "test", datetime = convert.todatetime("2017-09-25") }); e.datasources.clear(); e.datasources.add(new microsoft.reporting.webforms.reportdatasource() { name = "dsmovements", value = movementlist }); //throw new notimplementedexception(); }
both of method written in web api controller. eventhandler hitting while debugging, after press f11 (step into) while debugging localreport_subreportprocessing
method not hitting. why localreport_subreportprocessing
method not hitting ?
any or answer appreciated.
event's not called when register / add
+=
them.
events called when owning class invokes it.
public class eventtest { void someoperation() { //do } public void run() { someoperation(); runfinished?.invoke(this, eventargs.empty); //invoke event, indicating has happened or finished } //the event public event eventhandler runfinished; } public class eventsubscriber { eventtest _et = new eventtest(); public eventsubscriber() { _et.runfinished += etrunfinished; //register method, called when event occurs (is invoked) } public void dosomething() { _et.run(); console.writeline("something completed."); } void etrunfinished(object sender, eventargs e) { console.writeline("my event handler executed."); } }
your handler called when event fires.
when registering +=
or -=
unregistering (add / remove) not invoked.
for more detailed tutorial please refer msdn.
Comments
Post a Comment