Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

How do I combine a delegate with an invoke

 

public delegate void FlowerDelegate(byte color);

public FlowerDelegate Flowerchosen;

 

Flowerchosen.begininvoke(...)

 

This will obviosuly works with begininvoke, but I want to make my calls synchrounously instead. How can I do that ?

Posted

The last two parameters of begininvoke are System.AsyncCallback and object.

The object is used to set the state_of_the_invoke, that you later can verify in your IsCompleted function

 

public void IsCompleted(IAsyncResult ar)

{

if (ar.AsyncState == state_of_the_invoke)

}

 

When I now use invoke, does it mean that I no longer can use state, or do I have to make a global function that keeps track of states ??

  • Administrators
Posted

If you are calling the delegate synchrounously then there is no need to track if it has completed - when the call returns it has completed / if it hasn't returned it hasn't completed.

The callback / asyncresult are only required when dealing with delegates in an asynchrounous way.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...