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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:27:18+00:00 2026-06-02T13:27:18+00:00

In a C# 4 application I use a task parallel library for processing web

  • 0

In a C# 4 application I use a task parallel library for processing web request in parallel.After getting the web response there is a need to update some global variables, I decided to add a lock block to update that variables. Is the lock statement is best option to obtain mutual exclusion? and what is the exact relation between number of lock statements(or size of lock block) in TPL and performance decrease of TPL?

  • 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-02T13:27:19+00:00Added an answer on June 2, 2026 at 1:27 pm

    The answer to your first question is: yes. And no. You can use a lock block, or you can use a Mutex, there is little practical difference (within the context of a single application).

    The answer to your second question is: there is no exact relation. You could have a million locks, but the performance will only decrease if they are blocking eachother, and will decrease dependant on how much they block. (Caveat: the act of locking in itself will incur a performance penalty.)

    The exact profile of your code will determine what the relationship is, and that will only really be known by running some tests and finding out.

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

Sidebar

Related Questions

I am wiling to have some pages of my application use a wiki based
I'm using Visual Studio to create my installation package. My application use some bitmap
In a WPF application I use .txt files for holding some information. An application
I'm using the TPL ( Task Parallel Library ) in .NET 4.0. I want
I'm developing add-on based application. Every add-on use scheduler. Loaded add-on schedule task. My
I have written a small Python application where I use PyGame for displaying some
How to make Async task execute repeatedly after some time interval just like Timer...Actually
I have created small test web application which makes use of LINQ to SQL.
I am using Ant's <parallel> task to perform multiple simultaneous targets that use <exec>
I have a Rails application that unfortunately after a request to a controller, has

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.