Re: Threading on Functions returning values

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • Re: ouvrir un document word =?ISO-8859-1?Q?=E0_partir_d=27un?= =?ISO-8859-1?Q?_progr
    ... invoke theDocument "getParagraphs" returning theParagraphs ... move String1 to ws-SendText ... *> The final string is converted to an object if required ... depending on ls-OUT-Length pic x. ...
    (comp.lang.cobol)
  • Re: Threading on Functions returning values
    ... People like you are very Important for this forum. ... delegate string MyDelegate; ... the delegate returns a value, so too does the Invoke() method. ...
    (microsoft.public.dotnet.framework)
  • Strange error validating XML against XSD
    ... This method has one parameter (string your_data). ... value that this parameter will actually have is the content of a XML ... invokes my web method and it fails exactly when the XSD is performed. ... But when these guys invoke the method, ...
    (microsoft.public.dotnet.framework.webservices)
  • Strange error validating XML against XSD
    ... This method has one parameter (string your_data). ... value that this parameter will actually have is the content of a XML ... invokes my web method and it fails exactly when the XSD is performed. ... But when these guys invoke the method, ...
    (microsoft.public.dotnet.xml)
  • Re: what is an event?
    ... Well you could, if 'i' was a property, and on the set code you can invoke an ... >> or can we write this event from scratch? ... > can then fire/raise it by executing the delegates which have subscribed ... >> i mean, can we invoke a function, when i is ...
    (microsoft.public.dotnet.languages.csharp)