I have a eventhandler like this code below :
viewer.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
And this method as a parameter for 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 those method is written in a WEB API Controller . The eventhandler is hitting while debugging, but after I press F11 (step into) while debugging the LocalReport_SubreportProcessing
method is not hitting. Why is LocalReport_SubreportProcessing
method not hitting ?
Any help or answer is really appreciated.
Event's are not called when you register / add
+=
them.
Events are called when the owning class invokes it.
public class EventTest
{
void SomeOperation()
{
//Do something
}
public void Run()
{
SomeOperation();
RunFinished?.Invoke(this, EventArgs.Empty); //Invoke the event, indicating that something has happened or finished
}
//The event itself
public event EventHandler RunFinished;
}
public class EventSubscriber
{
EventTest _ET = new EventTest();
public EventSubscriber()
{
_ET.RunFinished += ETRunFinished; //Register my method, called when the event occurs (is invoked)
}
public void DoSomething()
{
_ET.Run();
Console.WriteLine("Something completed.");
}
void ETRunFinished(object sender, EventArgs e)
{
Console.WriteLine("My event handler was executed.");
}
}
Your handler will be called when the event fires.
When registering +=
or -=
unregistering (add / remove) they will NOT be invoked.
For a more detailed tutorial please refer to MSDN.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.