Connecting Tech Pros Worldwide Forums | Help | Site Map

Any performance issues using CallByName?

Rob R. Ainscough
Guest
 
Posts: n/a
#1: Nov 21 '05
I use a generic Processing form (modal) where I pass it an object and method
name and parameters if needed and then use CallbyName to execute the passed
in method. What this does for me is lock out user input on the parent form
as the Processing form has no input controls until all processing is
complete.

I was curious if CallByName is a good way to perform this operation?



Samuel R. Neff
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Any performance issues using CallByName?



It would be better if all the objects passed in implemented the same
interface and the modal form called a known method. Any params can be
stored within the object instance ahead of time or passed as a generic
object array.

Another way to handle this is to use delegates.. pass a delegate to
the form allong with an object array of params, and the form can
invoke the delegate. This would work fine but in my opinion the
interface method is a cleaner implementation.

CallByName uses late binding and reflection internally and has a lot
of overhead that isn't necessary for the task.

HTH,

Sam


On Fri, 7 Jan 2005 10:13:02 -0800, "Rob R. Ainscough"
<robains@pacbell.net> wrote:
[color=blue]
>I use a generic Processing form (modal) where I pass it an object and method
>name and parameters if needed and then use CallbyName to execute the passed
>in method. What this does for me is lock out user input on the parent form
>as the Processing form has no input controls until all processing is
>complete.
>
>I was curious if CallByName is a good way to perform this operation?
>[/color]

Rob R. Ainscough
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Any performance issues using CallByName?


Unfortunately the purpose of the Processing form is to be generic in nature
so the methods and objects are not known ahead of time. The CallByName is
only used once (not used in a loop).

Do you have any specific numbers to indicate the overhead of CallByName vs.
another approach?

Thanks, Rob.

"Samuel R. Neff" <blinex@newsgroup.nospam> wrote in message
news:l9ltt01uv3lfb431tg91cmd9sgcveq49p6@4ax.com...[color=blue]
>
> It would be better if all the objects passed in implemented the same
> interface and the modal form called a known method. Any params can be
> stored within the object instance ahead of time or passed as a generic
> object array.
>
> Another way to handle this is to use delegates.. pass a delegate to
> the form allong with an object array of params, and the form can
> invoke the delegate. This would work fine but in my opinion the
> interface method is a cleaner implementation.
>
> CallByName uses late binding and reflection internally and has a lot
> of overhead that isn't necessary for the task.
>
> HTH,
>
> Sam
>
>
> On Fri, 7 Jan 2005 10:13:02 -0800, "Rob R. Ainscough"
> <robains@pacbell.net> wrote:
>[color=green]
>>I use a generic Processing form (modal) where I pass it an object and
>>method
>>name and parameters if needed and then use CallbyName to execute the
>>passed
>>in method. What this does for me is lock out user input on the parent
>>form
>>as the Processing form has no input controls until all processing is
>>complete.
>>
>>I was curious if CallByName is a good way to perform this operation?
>>[/color]
>[/color]


Samuel R. Neff
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Any performance issues using CallByName?



So what's wrong with using a Delegate? That's generic.

I don't think CallByName would be a performance problem in your case
since it's only called once for a large operation, but in my opinion
it's a bad function to use. I fall in "program the VB.NET without VB
camp". In general, when a OOP/.NET mechanism exists to accomplish the
same goal, I would opt for that alternative. Delegates would work
well for your situation.

Sam


On Fri, 7 Jan 2005 11:13:56 -0800, "Rob R. Ainscough"
<robains@pacbell.net> wrote:
[color=blue]
>Unfortunately the purpose of the Processing form is to be generic in nature
>so the methods and objects are not known ahead of time. The CallByName is
>only used once (not used in a loop).
>
>Do you have any specific numbers to indicate the overhead of CallByName vs.
>another approach?
>
>Thanks, Rob.
>[/color]

Rob R. Ainscough
Guest
 
Posts: n/a
#5: Nov 21 '05

re: Any performance issues using CallByName?


Sam,

Hmmm...yes the Delegates approach may just work for me -- and appears it
might be about the same coding effort.

Thanks, Rob.

"Samuel R. Neff" <blinex@newsgroup.nospam> wrote in message
news:diott0lvp5avitibmq9916ub0i20q0nqbf@4ax.com...[color=blue]
>
> So what's wrong with using a Delegate? That's generic.
>
> I don't think CallByName would be a performance problem in your case
> since it's only called once for a large operation, but in my opinion
> it's a bad function to use. I fall in "program the VB.NET without VB
> camp". In general, when a OOP/.NET mechanism exists to accomplish the
> same goal, I would opt for that alternative. Delegates would work
> well for your situation.
>
> Sam
>
>
> On Fri, 7 Jan 2005 11:13:56 -0800, "Rob R. Ainscough"
> <robains@pacbell.net> wrote:
>[color=green]
>>Unfortunately the purpose of the Processing form is to be generic in
>>nature
>>so the methods and objects are not known ahead of time. The CallByName is
>>only used once (not used in a loop).
>>
>>Do you have any specific numbers to indicate the overhead of CallByName
>>vs.
>>another approach?
>>
>>Thanks, Rob.
>>[/color]
>[/color]


Mike McIntyre
Guest
 
Posts: n/a
#6: Nov 21 '05

re: Any performance issues using CallByName?


For some info on the performance hit see:

http://msdn.microsoft.com/library/de...stringname.asp


--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"Rob R. Ainscough" <robains@pacbell.net> wrote in message
news:uxVJISO9EHA.3504@TK2MSFTNGP12.phx.gbl...[color=blue]
>I use a generic Processing form (modal) where I pass it an object and
>method name and parameters if needed and then use CallbyName to execute the
>passed in method. What this does for me is lock out user input on the
>parent form as the Processing form has no input controls until all
>processing is complete.
>
> I was curious if CallByName is a good way to perform this operation?
>[/color]


Dennis
Guest
 
Posts: n/a
#7: Nov 21 '05

re: Any performance issues using CallByName?


See MethodInfo Class and it's .Invoke member

Dim myType As Type = objClass.GetType()
Dim myMethod As MethodInfo = myType.GetMethod("strFnName")
myMethod.Invoke(objClass, Args)

where "strFnName" is your method name and "Args" is an array of parameter
values (objects) for the method's arguments in the same order.


"Rob R. Ainscough" wrote:
[color=blue]
> I use a generic Processing form (modal) where I pass it an object and method
> name and parameters if needed and then use CallbyName to execute the passed
> in method. What this does for me is lock out user input on the parent form
> as the Processing form has no input controls until all processing is
> complete.
>
> I was curious if CallByName is a good way to perform this operation?
>
>
>[/color]
Mike McIntyre
Guest
 
Posts: n/a
#8: Nov 21 '05

re: Any performance issues using CallByName?


For some info on the performance hit see:

http://msdn.microsoft.com/library/de...stringname.asp


--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"Rob R. Ainscough" <robains@pacbell.net> wrote in message
news:uxVJISO9EHA.3504@TK2MSFTNGP12.phx.gbl...[color=blue]
>I use a generic Processing form (modal) where I pass it an object and
>method name and parameters if needed and then use CallbyName to execute the
>passed in method. What this does for me is lock out user input on the
>parent form as the Processing form has no input controls until all
>processing is complete.
>
> I was curious if CallByName is a good way to perform this operation?
>[/color]


Dennis
Guest
 
Posts: n/a
#9: Nov 21 '05

re: Any performance issues using CallByName?


See MethodInfo Class and it's .Invoke member

Dim myType As Type = objClass.GetType()
Dim myMethod As MethodInfo = myType.GetMethod("strFnName")
myMethod.Invoke(objClass, Args)

where "strFnName" is your method name and "Args" is an array of parameter
values (objects) for the method's arguments in the same order.


"Rob R. Ainscough" wrote:
[color=blue]
> I use a generic Processing form (modal) where I pass it an object and method
> name and parameters if needed and then use CallbyName to execute the passed
> in method. What this does for me is lock out user input on the parent form
> as the Processing form has no input controls until all processing is
> complete.
>
> I was curious if CallByName is a good way to perform this operation?
>
>
>[/color]
Closed Thread


Similar Visual Basic .NET bytes