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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:17:12+00:00 2026-05-12T18:17:12+00:00

I have two functions that I want to run on different threads (because they’re

  • 0

I have two functions that I want to run on different threads (because they’re database stuff, and they’re not needed immediately).

The functions are:

            getTenantReciept_UnitTableAdapter1.Fill(rentalEaseDataSet1.GetTenantReciept_Unit);
            getTenantReciept_TenantNameTableAdapter1.Fill(rentalEaseDataSet1.GetTenantReciept_TenantName);

In javascript, I know I can create create an anonymous function and call it on a new thread quite easily with something like this:

setTimeout(new function(){doSomethingImportantInBackground();}, 500);

Is there something like this in C#?

  • 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-12T18:17:12+00:00Added an answer on May 12, 2026 at 6:17 pm

    Your question isn’t very clear, I’m afraid. You can easily start a new thread with some code, using anonymous methods in C# 2, and lambda expressions in C# 3:

    Anonymous method:

    new Thread(delegate() {
        getTenantReciept_UnitTableAdapter1.Fill(
            rentalEaseDataSet1.GetTenantReciept_Unit);
    }).Start();
    new Thread(delegate() {
        getTenantReciept_TenantNameTableAdapter1.Fill(
            rentalEaseDataSet1.GetTenantReciept_TenantName);
    }).Start();
    

    Lambda expression:

    new Thread(() =>
        getTenantReciept_UnitTableAdapter1.Fill(
            rentalEaseDataSet1.GetTenantReciept_Unit)
    ).Start();
    new Thread(() =>
        getTenantReciept_TenantNameTableAdapter1.Fill(
            rentalEaseDataSet1.GetTenantReciept_TenantName)
    ).Start();
    

    You can use the same sort of syntax for Control.Invoke, but it’s slightly trickier as that can take any delegate – so you need to tell the compiler which type you’re using rather than rely on an implicit conversion. It’s probably easiest to write:

    EventHandler eh = delegate
    {
        // Code
    };
    control.Invoke(eh);
    

    or

    EventHandler eh = (sender, args) =>
    {
        // Code
    };
    control.Invoke(eh);
    

    As a side note, are your names really that long? Can you shorten them to get more readable code?

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

Sidebar

Related Questions

I have two functions that have different enough logic but pretty much the same
Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);
So I have two jquery functions that bassically do the same, but on 2
I have two functions to add and remove table rows that contain a form
I have two functions in an ActionScript class, they are: private function loaderCompleteHandler(event:Event):void {
I have a WinForms Application that I want to run at Mono at some
I have two apps. which current run in two different ports. script1.js: var express
We are working on integrating two different applications that run simultaneously and share data.
I have a CPU consuming function do_long that I need to run on two
I have two classes that each need an instance of each other to function.

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.