Class A is a user-defined control: It's basically a window that
contains a panel and a paging navigator (with the back and forward
arrow buttons).
Class B is a class that instantiates class C to generate an array of
report objects.
Class C is a class that starts the invokes the printdocument.Print
object, and it takes care of printing each page of the report.
The graphics of each report page is passed back to Class A via the
generic event of OnEndPage of the print controller that takes
PageEventArgs as parameter, so the panel in Class A would show the
report page.
The original design works all fine until now I need to pass something
more than just what the PageEventArgs hold (graphics, bounds,
hasmorepages etc.). What I need to do is to pass an array of
information that contains the page number and the object of the report
back to Class A for future use. Since I can't use the same way of
passing the graphics back (the OnEndPage event), I need to come up with
some event on my own - Each time when a page is generated, my array
needs to be passed back to Class A. Please note that drawing each page
happens on worker thread while Class A is in the main thread.
I've got an idea of how to pass info from worker thread to main thread
- by using
MdiForm.BeginInvoke(new EventHandler(UpdatePageObjectReference),
pList);
in which pList is the array I need to pass over.
I defined the event handler "UpdatePageObjectReference" in Class A, but
at this point, in Class C, I don't hold an instance of Class A so it
won't recognize "UpdatePageObjectReference" event handler.
Please let me know about your thoughts.
Thanks,
Li
Bruce Wood wrote:
This strikes me as a design problem that requires a larger knowledge
of your problem domain.
What are you trying to do? What are A, B, and C? When does the data
need to be passed back and what does that mean in domain terms?