Connecting Tech Pros Worldwide Help | Site Map

Pass parameter to a delegate

Curious
Guest
 
Posts: n/a
#1: Oct 11 '07
I have a C#.NET program that uses a delegate,
"BuildExistingReportFile". It's called in such a fashion:

IList lFiles = this.GetListFromStoredProcedure(
null,
Constants.StoredProcedures.SPcorReportInstanceFile sGet,
new BuildDelegate(new
ReportClosure(aReport).BuildExistingReportFile),
new SqlParameter("@ReportInstanceID",aReport.ID));

I don't see any parameter passed to "BuildExistingReportFile".
However, it's defined as below:

public object BuildExistingReportFile(IRecord aRecord)
{
\\blah blah
}

Now I want to add an integer type of parameter, "counter", to this
delegate. How can I pass this parameter in?

Thanks!

Mattias Sjögren
Guest
 
Posts: n/a
#2: Oct 11 '07

re: Pass parameter to a delegate


>I have a C#.NET program that uses a delegate,
Quote:
>"BuildExistingReportFile". It's called in such a fashion:
Looks like the delegate type is actually called BuildDelegate and that
BuildExistingReportFile is the method that the delegate object will
call.

Quote:
>Now I want to add an integer type of parameter, "counter", to this
>delegate. How can I pass this parameter in?
- Modify the delegate type (BuildDelegate).
- Modify the method signature to match (BuildExistingReportFile).
- Modify the calling code (probably somewhere inside
GetListFromStoredProcedure).


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Curious
Guest
 
Posts: n/a
#3: Oct 11 '07

re: Pass parameter to a delegate


Mattias,

Thanks for the valuable advice! Sounds like the way to go. I'll try it
out. In case I have question, I'll ask again.

Closed Thread