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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:36:51+00:00 2026-06-01T18:36:51+00:00

I have many web service call (asychronous), in callback, I will plot result to

  • 0

I have many web service call (asychronous), in callback, I will plot result to Excel.
I want to synchronize the plot method.
So I use the following, however, from I track down in Visual Studio, every time, lock(locker) is successful, and there are many threads running clearcommentIfany, plot.
I can’t figure out why this is not working as expected! Thanks

private readonly object locker = new object();

void ProcessPlot()
{
    lock (locker)
    {
        Debug.WriteLine("currentThreadID: " + Thread.CurrentThread.ManagedThreadId);
        //Helper.Dispatcher.Invoke(new AddClearCommentDelegate(ClearCommentIfAny));
        ClearCommentIfAny();

        if (Response.status != Status.COMPLETE)
        {
            ErrorMessage = ManipulateStatusMsg(Response);
            //Helper.Dispatcher.Invoke(new AddClearCommentDelegate(AddCommentToCell));
            AddCommentToCell();
        }
        else // COMPLETE
        {
            // TODO: Convert this into factory pattern
            Debug.WriteLine("ReportBuilder.Dispatcher's address " + Helper.GetAddress(Helper.Dispatcher));
            //Helper.Dispatcher.Invoke(new PlotDelegate(Plot), Response);
            Plot(Response);
        }               
    } 
}

public void DataRequestJobFinished(DataRequestResponse response)
{
    try
    {
        if (Request.IsRequestCancelled)
        {
            Request.FormulaCell.Dispose();
            return;
        }

        Response = response;

        //if (response.status != Status.COMPLETE)
        //{
        //    ErrorMessage = ManipulateStatusMsg(response);
        //}
        //else // COMPLETE
        //{
        //    // TODO: Convert this into factory pattern
        //    PlotDelegate plotDelegate = Plot;
        //    Debug.WriteLine("ReportBuilder.Dispatcher's address " + Helper.GetAddress(Helper.Dispatcher));
        //    Helper.Dispatcher.Invoke(plotDelegate, response);
        //    //Plot(response);                 
        //}
        var t = new Thread(ProcessPlot);
        t.Start();
        //ProcessPlot();
    }
    catch (Exception e)
    {
        ErrorMessage = e.Message;
        MIMICShared.Helper.LogError(e);
    }
    finally
    {
        //TODO: PutReportBuilderInQueue(this);
        ReadyForPlot = true;
        //Request.FormulaCell.Dispose(); move this after plot
        UnityContainer.Resolve<IEventAggregator>().GetEvent<DataRefreshEvent>().Publish(ID);
    }
}
  • 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-01T18:36:52+00:00Added an answer on June 1, 2026 at 6:36 pm

    I suspect your problem here is that your lock is an instance member rather than a static (type level) member.

    Assuming that each thread has its own instance of the containing class, then it’ll also have its own instance of your locker – which is not what you want.

    Try this declaration instead:

    private static readonly object locker = new object();
    

    The inclusion of the static keyword now makes this object instance exist at the type level, i.e. shared across all instances of your class.

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

Sidebar

Related Questions

I'm using Grails and want to use groovyws to call an web-service. But my
In my web application we have many users.I want to set permission for each
I need to call a web service from my classic ASP website. I have
For the first time, I am writing a web service that will call upon
I have a simple web service method that returns a simple java class as
We have a web service coded in C# that makes many calls to MS
I am new to titanium and and want to call a web service from
I'm using webservice to call other services. And I have to call many services
I have a database that many different client applications (a smattering of web services,
I have to run a Web server with many services on an embedded server

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.