Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3486132
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:59:31+00:00 2026-05-18T10:59:31+00:00

In Silverlight I use lambdas for data retrieval from my service (in this example

  • 0

In Silverlight I use lambdas for data retrieval from my service (in this example a WCF Data Service). Exceptions inside the callback get swallowed up by the system unless I handle them with a try catch. For Example:

this.Context.BeginSaveChanges(() =>
{
  // throwing an exception is lost and the Application_UnhandledException doesn't catch it

}, null);

I have a helper function to log the exception and redirect to a aspx general error page, but then I have to wrap everything in lambdas with try/catches which is ok, if I have to do it, but is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:59:31+00:00Added an answer on May 18, 2026 at 10:59 am

    You could create a set of helper methods to wrap the lambda’s with:-

     public static class Helper
     {
        public static AsyncCallback GetAsyncCallback(Action<IAsyncResult> inner)
        {
            return (a) =>
            {
                try
                {
                    inner(a);
                }
                catch (Exception err)
                {
                    // Your handling for "uncaught" errors
                }
            };
        }
    
        public static Action GetAction(Action inner)
          {
             return () =>
             {
                 try
                 {
                     inner();
                 }
                 catch (Exception err)
                 {
                     // Your handling for "uncaught" errors
                 }
             };
          }
    
          public static Action<T> GetAction(Action<T> inner)
          {
             return (a) =>
             {
                 try
                 {
                     inner(a);
                 }
                 catch (Exception err)
                 {
                     // Your handling for "uncaught" errors
                 }
             };
          }
          // and so on also:-
    
          public static Func<T> GetFunc(Func<T> inner;)
          {
             return () =>
             {
                 try
                 {
                     return inner();
                 }
                 catch (Exception err)
                 {
                     // Your handling for "uncaught" errors
                 }
             };
          }
          public static Func<T1, TReturn> GetFunc(Func<T1, TReturn> inner;)
          {
             return (a) =>
             {
                 try
                 {
                     return inner(a);
                 }
                 catch (Exception err)
                 {
                     // Your handling for "uncaught" errors
                 }
             };
          }
     }
    

    Now you can wrap lambda’s without worrying about default boilerplate exception handling:-

    this.Context.BeginSaveChanges(Helper.GetAsyncCallback((ar) =>             
    {             
      // Only needs specific exception handling or none at all             
    
    }), null);             
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have downloaded the silver light from this http://www.microsoft.com/silverlight// I need to use this
Duplicate: How do I use Silverlight from ASP.NET? How do I add some Silverlight
If I decided to use Silverlight, does this mean that I'm no longer working
Can any one tell me how to use Silverlight to play audio from local
Silverlight can use WCF, Web Services, REST based services, .NET RIA Services, but it
I started to use silverlight/flex and immediately bumped into the asynchronous service calling. I'm
I rewrite application from ASP.NET to Silverlight and use NHibernate 2. Tables in my
Should one use the generated WCF service client (e.g. MyServiceClient) when invoking a WCF
I need my ASP.NET web application to use silverlight controls in my web page.
Can we use Java in Silverlight?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.