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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:06:26+00:00 2026-06-05T14:06:26+00:00

I have a thread, I need to call a void like this : makegraph(toplot,

  • 0

I have a thread, I need to call a void like this :

makegraph(toplot, ite, mm_0)

However if I want to synchronize I should use SynchronizationContext and do :

SynchronizationContext mContext = null;
mContext.Post(new SendOrPostCallback(makegraph(toplot, ite, mm_0)),null);

But I have the followinf error : Method name expected .
I know that I should use delegates but I am not familiar with the syntax.

Can you help me on that please ?

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

    First off, your mContext variable is never set to an instance of SynchronizationContext, it’s initialized to null.

    The function SynchronizationContext.Post() expects two arguments, one of type SendOrPostCallback, and one of type object.

    • If you look at the documentation for SendOrPostCallback, it is a delegate that returns void and expects a single object parameter as input.
    • The object state parameter of the Post function is the parameter that will get passed into the delegate specified in the first paramter.

    That means, you will need to make a new makegraph function that matches the signature of the SendOrPostCallback delegate, and then pass in all of the paramters in a single object, like so:

    public class MakeGraphState()
    {
        // These don't have to be objects, but I don't know
        // what types your toplot, ite, and mm_0 paramters are
        public object toplot { get; set; }
        public object ite { get; set; }
        public object mm_0 { get; set; }
    }
    
    public static void makegraph(object state)
    {
        // Convert state to a MakeGraphState so we can get
        // all of the input paramters
        MakeGraphState myState = (MakeGraphState)object;
        makegraph(myState.toplot, myState.ite, myState.mm_0);
    }
    

    You could then use this code like so:

    SynchronizationContext mContext = new SynchronizationContext();
    // TODO: Initialize your SynchronizationContext
    MakeGraphState state = new MakeGraphState(toplot, ite, mm_0);
    mContext.Post(new SendOrPostCallback(makegraph), state);
    

    In addition, you can just pass in your method name for the delegate as a shortcut:

    SynchronizationContext mContext = null;
    // TODO: Initialize your SynchronizationContext
    MakeGraphState state = new MakeGraphState(toplot, ite, mm_0);
    mContext.Post(makegraph, state);
    

    For more info on delegates, see the MSDN article Delegates (C# Programming Guide)
    .

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

Sidebar

Related Questions

I have a thread containing a runnable. I need this to loop infinitely unless
I have thread where downloading xml file a this xml file i want to
I have a simple server that looks something like this: void *run_thread(void *arg) {
I am using ACE threads and need each thread to have its own int
I have to create a progress bar in a webapp. I need a thread
I need to kill specific worker thread in my application. I don't have any
The problem is this: I have multiple competing threads (100+) that need to access
I am aware that System.Threading.Timer exists, but I already have a Thread. This thread
I have a class like this: public FooRepo : IFooRepo { public FooRepo(IDbContextFactory factory)
In my android service, I'm starting a new thread like this thread = new

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.