Re: Threading on Functions returning values
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Thu, 26 Jul 2007 21:46:13 -0700
On Thu, 26 Jul 2007 20:54:00 -0700, A.K.Seerajdeen <siraj@xxxxxxxxxxxxxxxxxx> wrote:
Hi Mr.Peter,
Thank you for responding to my query. I could able to understand the =
explaination given below by you. I have tried the way which you have =
explained but I am not able to do the coding has you have mentioned =
since lack of idea in delegates. It will be more helpful if you could =
explain me in terms of coding.
As an example:
delegate string MyDelegate();
void InvokingMethod()
{
string strT;
strT = (string)this.Invoke((MyDelegate)InvokedMethod);
}
string InvokedMethod()
{
return "This is a test string";
}
In other words, it works just like calling a method directly, in that when the delegate returns a value, so too does the Invoke() method. Just cast the return value from Invoke() to whatever you need, and as long as the cast matches the actual return type of the invoked method, it will work fine.
If the above does not solve the issue, I recommend that you read the MSDN documentation on delegates as well as the Control.Invoke() method. If you still have questions, please feel free to post them, but do make sure that the questions are specific enough to be able to answered in a straight-forward way. It would be especially useful if you phrase the question in terms of what in the documentation you are having trouble understanding.
Pete
.
- Follow-Ups:
- Re: Threading on Functions returning values
- From: A.K.Seerajdeen
- Re: Threading on Functions returning values
- References:
- Threading on Functions returning values
- From: A.K.Seerajdeen
- Re: Threading on Functions returning values
- From: ivar
- Re: Threading on Functions returning values
- From: Benny Skjold Tordrup
- Re: Threading on Functions returning values
- From: ivar
- Re: Threading on Functions returning values
- From: Peter Duniho
- Re: Threading on Functions returning values
- From: A.K.Seerajdeen
- Threading on Functions returning values
- Prev by Date: Re: Threading on Functions returning values
- Next by Date: RE: Event for activating "title" bar in WPF
- Previous by thread: Re: Threading on Functions returning values
- Next by thread: Re: Threading on Functions returning values
- Index(es):
Relevant Pages
|