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

  • Home
  • SEARCH
  • 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 6116717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:14:18+00:00 2026-05-23T15:14:18+00:00

public virtual IAsyncResult BeginProcessRequest(RequestContext context, AsyncCallback callback, object state) { return this.process.BeginInvoke(**ref context**, callback,

  • 0
public virtual IAsyncResult BeginProcessRequest(RequestContext context, AsyncCallback callback, object state)
{
    return this.process.BeginInvoke(**ref context**, callback, state);
}

public virtual RequestContext EndProcessRequest(IAsyncResult result)
{
    RequestContext context = null;
    this.process.EndInvoke(**ref context**, result);
    return context;
}

The two methods above are causing some warnings in my project. I’m not sure I understand them. The warning is:

Argument is ‘ref’ while parameter is declared as ‘value’

and the location of the warning is the first parameter (context) in the Invoke calls. Does anyone see anything wrong with this or have some advice about the issue?

Those double asterisks are the cause of the warnings. I hit “bold” on the editor and it did that so I just went with it. The asterisks are not in my code.

  • 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-23T15:14:19+00:00Added an answer on May 23, 2026 at 3:14 pm

    Using ref with delegates is a bad idea, IMO. (I’d say it’s normally a bad idea anyway, to be honest. Make your methods do one thing and have one result.)

    I didn’t think it would work at all – but apparently it does, so long as you supply the ref parameter when you call EndInvoke as well:

    using System;
    
    class Program
    {
        delegate void Foo(ref int x, string y);
    
        static void SampleFoo(ref int x, string y)
        {
            Console.WriteLine("Incoming: {0}", x); // 10
            x = y.Length;
        }
    
        static void Main(string[] args)
        {
            int x = 0;
            int input = 10;
            Foo f = SampleFoo;
            IAsyncResult result = f.BeginInvoke(ref input, "Hello", null, null);
            f.EndInvoke(ref x, result);
            Console.WriteLine("Result: {0}", x); // 5
        }
    }
    

    The behaviour here is potentially confusing… I would avoid it if at all possible.

    Most uses of ref are due to not understanding how parameter passing works in C#… is it possible that that’s the case here? Do you really need the first parameter to be ref? Can you just make the return value of the delegate the new context instead?

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

Sidebar

Related Questions

public class Parent { public virtual Parent me() { return this; } } public
I have this method to unit test: public virtual TEntity Get(int id) { return
I have the following code: public virtual void Initialise() { this.AddHeader(SystemContext, this.UserSettings.SystemContext); } public
take this simple code: class A{ public: virtual void foo() = 0; void x(){
If I have the following domain object: public class Customer { public virtual Guid
I have this class: public class MyEntity { public virtual int Id { get;
i have got this code: class father{ public: virtual void f() { cout<<1;} };
I am returning partial view public virtual PartialViewResult Create() { return PartialView(Create); } and
I have a model like this: public PurchaseOrder { [Required] [StringLength(15)] public virtual string
This doesn't work: class Foo { public: virtual int A(int); virtual int A(int,int); };

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.