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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:01:25+00:00 2026-06-01T17:01:25+00:00

public delegate bool FunctieCompara(int a, int b); this is the delegate Simple function calls:

  • 0
public delegate bool FunctieCompara(int a, int b); this is the delegate

Simple function calls:

TyG.bubbleSort(TyG.max, TyG.Lungime, TyG.Secv);
TyG.bubbleSort(TyG.min, TyG.Lungime, TyG.secvMin);

I have a Class Sorts and in this class I have a lot of methods like

public void bubbleSort(functionDelegate f, int n, int [] v)

and much more sorts but with this parameters. In other class I have a instance of

Sortst tyg = new Sorts()

I want to create a thread

Thread Thr = new Thread(new ThreadStart(tyg.bubbleSort(functionDelegate)))

I didn’t figure it out this thing works in my case, how can i use thread with a method that use a delegate, in my case the delegate is a max/min for comparing numbers for doing sorts in place in v[]. I want to make 2 threads for doing the both sorts bubbleSort(max, n, v) and bubbleSort(min, n, v) same time. That is what thread does anyway, anyhow can anyone help me a little please?

  • 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-01T17:01:27+00:00Added an answer on June 1, 2026 at 5:01 pm

    Do you mean like this?

    var t1 = new Thread(
       o =>
       {
           tyg.bubbleSort(max, n, v1);
       });
    
    var t2 = new Thread(
       o =>
       {
           tyg.bubbleSort(min, n, v2);
       });
    
    t1.Start(); // start threads
    t2.Start();
    
    t1.Join(); // wait for both threads to finish
    t2.Join();
    

    Note that if you are sorting in place you should use different arrays (v1 and v2) because otherwise the threads will be overwriting the same array.

    If you are interested, also look over the Task construct of .NET 4.0.

    Alternatively, if you want to be cool (.NET 4.0+):

    Parallel.Invoke(
        () => tyg.bubbleSort(max, n, v1),
        () => tyg.bubbleSort(min, n, v2));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public void MyTest() { bool eventFinished = false; myEventRaiser.OnEvent += delegate { doStuff(); eventFinished
public class SendImage { public delegate int DWatch(int bytesLeftToSend, IntPtr Response); ret=0xffff; public void
I declared a delegate: public delegate void Del(string message); Then i created a function
Consider the delegate for a generic A to B function: public delegate B Fun<A,
I have this delegate in C#. public delegate string ACSharpDelegate(string message); How would I
I am developing a generic wrapper around TryParse, as follows: public delegate bool ParseDelegate<T>(string
I understand that predicates are delegate to function which return bool and take generic
I have a class called NTree: class NTree<T> { delegate bool TreeVisitor<T>(T nodeData); public
I've got the following function in a C++/CLI class library DLL: public delegate void
Below function working ok but I want to make it simple. if (list.Exists(delegate(string s)

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.