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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:47:32+00:00 2026-06-17T20:47:32+00:00

Initial Situation I’m developing a .NET Framework 4.0, C#, Winform Application. The Application will

  • 0

Initial Situation

I’m developing a .NET Framework 4.0, C#, Winform Application. The Application will list (and test) WebServiceOperations in a GridView (with currently 60 DataRows => WebServiceOperations).

Objective

I have to test/call all of this operations with one click on a button. Every operation creates a new instance of a class. Within this class, i call the WebServiceOperation async and wait for the result. The result is then beeing validated. The whole code works smooth using delegates and events.

Now it comes to the challenge/question: When clicking on that button, i use a for loop (int i = 0; i < gridViewWsOperations.RowCount; i++) => with other words, currently i’m firing 60 operations at them ‘same time’ => the Server gets overloaded processing 60 requests at the same time and i get timeouts. So i need to somehow throttle the number of concurrend requests to let’s say 10 at the same time.
Consider, the for loop (where i have to enqueue the requests) isn’t in the same thread as the method (process_result event) where i dequeue the requests. I tried it using ConcurrentQueue since this type of collection seems to be thread-safe.

Links

ConcurrentQueue at MSDN

a sample code would really help!

— this is my solution/sample code —

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Concurrent;
using System.Threading;

namespace ConcurrentQueueSample
{
    class Program
    {
        static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(3);

        static void Main(string[] args)
        {
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            timer.Interval = 1234;
            timer.Enabled = true;
            timer.Start();

            for (int i = 0; i < 10; i++) new Thread(go).Start(i);
        }

        static void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            semaphoreSlim.Release();
        }

        static void go(object i)
        {
            Console.WriteLine("id: {0}", i);
            semaphoreSlim.Wait();
            Console.WriteLine("id: {0} is in", i);
            Thread.Sleep(1250);
            Console.WriteLine("id: {0} left!", i);
        }
    }
}
  • 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-17T20:47:33+00:00Added an answer on June 17, 2026 at 8:47 pm

    You may want to take a look at using the SemaphoreSlim class to throttle the threads that have access to your queue.

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

Sidebar

Related Questions

Situation:I have an ASP .NET application that will search through docs using Lucene. I
Initial situation: I am working with a proprietary framework ( ESRI 's ArcGIS Engine
I'll re-explain my situation because i think my initial story wasn't clear enough. Im
Initial tests indicate that GDI+ (writing in VB.NET) is not fast enough for my
My initial task was to find a segmenter for Windows that will split a
In my application my initial view controller pushes a UITabBarController modally which has 4
The initial situation is that I map my domain model into a presentation model.
Here is the situation, I have a login page as the initial rootView of
I have a WPF/C# situation where I have a horizontal list of items and
I'm writing my own CMS and have the situation where the some initial settings

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.