Why asynchronous calls in silverlight




















Remove From My Forums. Answered by:. Archived Forums. Programming Silverlight with. NET — General. NET applications. Sign in to vote. There's got to be a better way! Gary Frank. If we run the calls pseudo-synchronously, by having each callback set up the next call, it will take 12 seconds before call 3 starts.

If calls 1 and 2 run in parallel, it will only take 7 seconds before call 3 can start. Using an additional helper class AsyncCoordinator , we can get the parallellism we want as follows:. At this point, I encourage you to download and run the attached sample, which contains a full implementation of a slightly more complex example, as well as the all important definition of the classes which make it all work.

If all you are looking for is a solution, you probably need go no further. If you want to understand how the code works, look out for a forthcoming article. The most interesting thing, for me, in coming up with this approach, was how little code was needed to make it all work. I suspect that in a language like F , it would be even smaller The most frustrating aspect was the need to use reflection as the only way of effectively passing the event handler into the helper class.

Why event handlers in C are treated in such an awkward way beats me. Sign in Email. Forgot your password? Search within: Articles Quick Answers Messages. Tagged as C. Stats Taming Silverlight Async Calls. Gary Bilkus Rate me:. Please Sign up or sign in to vote. A helper class to simplify and enhance Silverlight async calls.

Download demo - Existing Members Sign in to your account. This email is in use. Do you need your password? Submit your solution!

When answering a question please: Read the question carefully. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.

Let's work to help developers, not make them feel stupid. Related Questions. How to use Asynchronous completed result in silverlight. Asynchronous calls to Database. Layout: fixed fluid. Web02 2. Strip HTML. When that returns, the UI gets populated with the data. Hopefully the blogger will take notice of this comment. Do use ThreadPool. QueueUserWorkItem to call a method on your business facade.

The implemented method will look like this:. BeginLogin username, password, null, null ; asyncResult. EndLogin asyncResult ;. The call to AsyncWaitHandle. WaitOne returned by the service itself will cause the thread to block until the call is done. This keeps your facade interface synchronous while calling the facade from the ThreadPool keeps your UI running. Hello, I was facing the same problem in making async calls to RIA service query.

So can I use the following code as you have suggested above? This site uses Akismet to reduce spam. Learn how your comment data is processed. Benjamin Day Consulting, Inc.



0コメント

  • 1000 / 1000