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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:51:24+00:00 2026-05-13T16:51:24+00:00

In this example I want to add a .loop({quantity},{sleepvalue}) to a method I got

  • 0

In this example I want to add a .loop({quantity},{sleepvalue}) to a method

I got it to work with this:

this.loop(count, 500,
  ()=>{
   var image = Screenshots.getScreenshotOfDesktop();
   pictureBox.load(image);
   images.Add(image);
   updateTrackBar();
  });

using this extension method:

public static void loop(this Object _object, int count, int delay, MethodInvoker methodInvoker)
  {
   for(int i=0; i < count; i++)
   {
    methodInvoker();
    _object.sleep(delay);
   }
  }

which means that the invocation syntax is:

this.loop(15,500, () => {...code...});

but ideally what I wanted to do was something like:

()=> { ...code...}.loop(10,500);

which doesn’t work unless I do it like this:

new MethodInvoker(()=>{...code...}).loop(10,500);

which will work with this version of the extension method:

public static void loop(this MethodInvoker methodInvoker, int count, int delay)
  {
   for(int i=0; i < count; i++)
   {
    methodInvoker();
    Processes.Sleep(delay);
   }
  }
  • 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-13T16:51:25+00:00Added an answer on May 13, 2026 at 4:51 pm

    No, unfortunately there isn’t.

    I blogged about this quite a while ago 🙁

    However, with the right choice of indentation, you can make it look almost identical to a normal loop:

    HelperType.Loop(count, 500, () =>
    {
       // Code here
    });
    

    That’s what a lot of the Parallel Extensions samples look like

    I wouldn’t make it an extension method on something you’re not actually going to use, just so that you can use “this” instead of the real type name… not unless you’ve got a real use for the object it’s called “on”, anyway.

    (I’d also suggest following .NET naming conventions – make your methods PascalCase.)

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

Sidebar

Ask A Question

Stats

  • Questions 489k
  • Answers 489k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try: List<String> keywords = // your words for (String key… May 16, 2026 at 9:07 am
  • Editorial Team
    Editorial Team added an answer I've used Andrew Valums' Ajax Upload in the past, and… May 16, 2026 at 9:07 am
  • Editorial Team
    Editorial Team added an answer Check out http://thinkhole.org/wp/2006/09/20/howto-connect-to-google-talk-with-bitlbee/ It is a command line client which… May 16, 2026 at 9:07 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

This is my 2-part question. My understanding is small so beer with me. This
Hello I'm trying something .. I was reading Jquery traversing documentations some forums, this
I'm using R to loop through a data frame, perform a calculation and to
When a user types in his username.example.com I read out the subdomain and render
I'm a jQuery newbie, so be gentle! I have a loop that outputs extra
Is there a way without using arrays to write the following with a loop:
I have a div with elements below it that I am serializing. I am
I am trying to dynamically create pagination links based on the total number of
Summary: I'd like to view my text in vim with a small bit of

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.