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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:31:20+00:00 2026-06-11T13:31:20+00:00

In some class method, A, I need to call a library method B, which

  • 0

In some class method, A, I need to call a library method B, which takes as an IProgress<Object> as a parameter.

Normally, I might either implement IProgress<Object> as part of class where A resides, and then pass “this” to method B. Or perhaps I might create a new class whose only purpose is to implement IProgress<Object> and handle it correctly– then in this case I’d create an instance of that class and pass it to B.

But what I really want is to have my implementation of IProgress<Object> to appear right inside the method in which I’m calling B, so that there’s less of a visual disconnect between the calling code, and the IProgress<Object> implementation. (I consider my implementation of IProgress to be kind of a private, non-shared detail of the calling method and thus I don’t want my implementation of IProgress<Object> to be in a whole separate method of perhaps a whole other class).

What I’ve been trying to do is use a lambda in which I will define my short progress handling, and then somehow pass this lambda to B, like this:

method in class A {
...
Action<Object> Report = (m) => { // do something useful with m };

B(Report)
}

method B(IProgress<Object> reporter) {
   reporter.Report(some object)
}

Of course, I know why this won’t work as is – B is wanting an object that implements IProgress<Object> and I’m handing it an Action object instead.

Is there any way to achieve what I’m trying to achieve? (IE have my implementation if IProgress<Object> appear inside method A?

  • 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-11T13:31:21+00:00Added an answer on June 11, 2026 at 1:31 pm

    Delegates cannot implement interfaces (directly).

    Two good options come to mind:

    1. Change the definition of the method that you’re calling to take a delegate types instead of an IProgress type. (If possible; this would be the preferable option)

    2. Create a new type that implements the interface that you need and takes a delegate as a parameter to implement that functionality.

    And example of #2, while dependent on the interface, might look something like this:

    interface IProgress<T>
    {
        void doStuff(T param);
    }
    
    class LambdaProgress<T> : IProgress<T>
    {
        Action<T> action;
        public LambdaProgress(Action<T> action)
        {
            this.action = action;
        }
    
        public void doStuff(T param)
        {
            action(param);
        }
    }
    

    then you’d be able to do something like:

    B(new LambdaProgress<Object>(obj => ...));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a c# class library. I need to to call a method in
I need some JS class or CSS method to create from any text such
I need a component/class that throttles execution of some method to maximum M calls
I've got following problem: (c#) There is some class (IRC bot), which has method,
I have a class with some method that depend by one parameter. What is
I've got a method in a class that's writing to some string, which calls
How to call Html.Partial() method from controller or some other method in external class
I am using a class library which represents some of its configuration in .xml.
I have some class that I'm passing as a result of a service method,
I have an abstract class with some methods,including an abstract method(Execute()).This method is overridden

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.