Jedhi Posted May 27, 2004 Posted May 27, 2004 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 ? Quote
Administrators PlausiblyDamp Posted May 27, 2004 Administrators Posted May 27, 2004 In C# you can just use the delegate like a normal function call i.e. Flowerchosen(3); the C# compiler will actually generate the code as if you had written Flowerchosen.Invoke(3) . Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jedhi Posted May 28, 2004 Author Posted May 28, 2004 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 ?? Quote
Administrators PlausiblyDamp Posted May 28, 2004 Administrators Posted May 28, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.