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 8654859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:53:23+00:00 2026-06-12T14:53:23+00:00

I have a Silverlight client using MEF/Prism that connects to a WCF service. I

  • 0

I have a Silverlight client using MEF/Prism that connects to a WCF service. I am writing a “service agent” to use as a shared service throughout the application. This “service agent” is a singleton that provides the only way for the client to call the WCF service. I’ve implemented my service contract and all of the methods look very similar, except for the specific Begin/End operations they call and the arguments they accept.

For example:

public void WakeUpInstanceAsync(Foo opportunity, bool isHistorical, Action<WakeupObj> callback)
{
    if (IsOpen())
    {
        AsyncCallback asyncCallback = (e) =>
        {
            _currentDispatcher.BeginInvoke(() =>
            {
                try
                {
                    callback(_funnelClient.EndWakeUpInstance(e));
                }
                catch (CommunicationException ex1)
                {
                    // Notify someone via eventaggregator?
                    callback(null);
                }
            });
        };

        _funnelClient.BeginWakeUpInstance(opportunity, isHistorical, asyncCallback, null);
    }
}

Is there any way I could create a generic method that takes a 2 parameters (the “begin” method and the “end” method)?

  • 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-06-12T14:53:25+00:00Added an answer on June 12, 2026 at 2:53 pm

    Would something like this be what you are looking for?

        public void WakeUpInstanceAsync(Foo opportunity, bool isHistorical, Action<WakeupObj> callback)
        {
            this.ImplementAsyncMethod(
                asyncCallback => _funnelClient.BeginWakeUpInstance(opportunity, isHistorical, asyncCallback, null),
                asyncResult => _funnelClient.EndWakeUpInstance(asyncResult),
                callback);
        }
    
        public void ImplementAsyncMethod<T>(Action<AsyncCallback> begin, Func<IAsyncResult, T> end, Action<T> callback)
        {
            if (IsOpen())
            {
                AsyncCallback asyncCallback = (e) =>
                {
                    _currentDispatcher.BeginInvoke(() =>
                    {
                        try
                        {
                            callback(end(e));
                        }
                        catch (CommunicationException ex1)
                        {
                            // Notify someone via eventaggregator?
                            callback(default(T));
                        }
                    });
                };
    
                begin(asyncCallback);
            }
        }
    

    (disclaimer – I have not compiled it)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service that receive query from a silverlight client and send
I have written a simplified Silverlight client library for my WCF web service using
I have a Silverlight application that connects to a WCF service. Under the basic
I have a set of webservices that I connect to using Silverlight Client. I
I have this setup that works perfectly when using http. A silverlight 3 client
I'm using WCF RIA Services and I have a domain service method that returns
I have a Silverlight application using a WCF service hosted in IIS. I make
I have a Silverlight client that I need to call a web service. The
I have a silverlight 2 beta 2 application that accesses a WCF web service.
I have a wcf sevice and silverlight client. My contract has callbacks and therefore

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.