[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Async Calls Problem

Posted on 2005-04-12
1
Medium Priority
?
296 Views
Last Modified: 2010-04-16
Hi guys, I have a problem with Async call and below is the logic of my code

Function A
{
Make array of size 2 of WaitHandle
Make 2 AsyncCallback
Make 2 delegate
Make 2 IAsyncResult from the 2 delegate with BeingInvoke by passing the AsyncCallback as first parameter and null as second
Insert the IAsyncResult to WaitHandle[0] and WaitHandle[1]
WaitHandle.WaitAll(WaitHandleIMade)
}

CallBackFunction1
{
Make arrya of size 2 of Waithandle
Make 2 delegate
Make 2 IAsyncResult from the 2 delegate with BeingInvoke
Insert the IAsyncResult to WaitHandle[0] and WaitHandle[1]
WaitHandle.WaitAll(WaitHandleIMade)
}

CallBackFunction2
{
Synchronous process some stuffs
}

The question i have is that, can I create and use delegate in my CallBack Function ?
Like what I am doing in CallBackFunction1.
Will this cause a problem with my WaitAll in Function A?
Is using AsyncCallback going to suffer any performance issue?
Or should I "pull" the status of the delegate to check to see if they are completed. (like Pulling every 5 minutes or so)
The delegate that I will be calling from Function A is expected to run for like couple hours.

Right now i am deciding whether I should use delegate with callback, or use pulling method. (or of course, you have a better way of getting it done !)

Thanks guys/gals :)
0
Comment
Question by:lordiano
1 Comment
 
LVL 4

Accepted Solution

by:
nachiket earned 2000 total points
ID: 13770244
Hi,

<<Your Question>>:The question i have is that, can I create and use delegate in my CallBack Function

<<ANS>>Yes you can. However make sure this is what you want to do. As I see what  u need is a chain of async calls. If the first step of Async call is done you start the next step of async.

<<Your Question>>: Like what I am doing in CallBackFunction1.
Will this cause a problem with my WaitAll in Function A?

<<ANS>> 2 waitHandles are deferent array so they have no connection with each other. However Why are you making things complex. If your aim is just that u want the function to wait till the delegates are finished. Use Delegate. Endinvoke(IAsyncResult processed) any how u are using delegates. Other wise use some simpler mechanism like Mutex (which is also a waithandle)!! However you may have a reason to use wait handlers If so we can discuss. If EndInvoke solves your problems we do not need to waste time!!

<<Your Question>>: Is using AsyncCallback going to suffer any performance issue?
<<ANS>> : No. i think it will be far better than polling!!

<<Your Question>>: Right now i am deciding whether I should use delegate with callback, or use pulling method.
<<ANS>> : I suggest if possible use Thread (not async delegates). because if you async delegates use ThreadPool threads. However if your application is not very huge you can carry on with delegates. I will not vote for Pulling method. However using thread will cause u completely redesign the way you are using. if there is only 2 delegates are used u can continue with delegate callbacks. however there is more than 20 delegates going to be used same time u should go for threads.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question