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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:01:00+00:00 2026-06-12T07:01:00+00:00

my case is: loop and thread are working parallel.. i want to stop the

  • 0

my case is:
loop and thread are working parallel.. i want to stop the execution of loop untill thread is done with its functionality, when the thread state is stopped, at that time i want to execute the loop further..

            for (int pp = 0; pp < LstIop.Count; pp++)
            {
                oCntrlImageDisplay = new CntrlImageDisplay();
                oCntrlImageEdit = new CntrlImageEdit();
                axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF();
                int pages = ConvertFileIntoBinary(LstIop[pp].Input, oCntrlImageEdit);
                oCntrlImageDisplay.ImgDisplay.Image = LstIop[pp].Output;
                oCntrlImageDisplay.ImgEditor.Image = oCntrlImageDisplay.ImgDisplay.Image;


                if (t1 == null || t1.ThreadState.ToString() == "Stopped")
                {
                    t1 = new Thread(() => convert(pages, LstIop[pp].Input, LstIop[pp].Output, stIop[pp].Temp));
                    t1.SetApartmentState(ApartmentState.STA);
                    t1.IsBackground = true;
                    CheckForIllegalCrossThreadCalls = false;
                    t1.Start();

                }
            }
  • 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-12T07:01:01+00:00Added an answer on June 12, 2026 at 7:01 am

    as the others have said, there is no point in threading here, but if your hell bent on it, do Async. just use .Invoke or, .begininvoke followed by a .endInvoke

    EX:

        delegate void T2();
    
        static void Main(string[] args)
        {
            T2 Thread = new T2(Work);
    
            while (true)
            {
                IAsyncResult result = Thread.BeginInvoke(null, null);
    
                //OTHER WORK TO DO
    
                Thread.EndInvoke(result);
            }
        }
    
        static void Work()
        {
           //WORK TO DO
        }
    

    using delegates is nice because you can specify return data, and send parameters

        delegate double T2(byte[] array,string text, int num);
    
        static void Main(string[] args)
        {
            T2 Thread = new T2(Work);
    
            while (true)
            {
                IAsyncResult result = Thread.BeginInvoke(null, null);
    
                //OTHER WORK TO DO
    
                double Returned = Thread.EndInvoke(result);
            }
        }
    
        static double Work(byte[] array, string text, int num)
        {
            // WORK TO DO
            return(3.4);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a thread that, when its function exits its loop (the exit is
I want to loop true certain elements, in this case all with the class
http://jsperf.com/testing-foreach-vs-for-loop It was my understanding that Test Case 2 should run more slowly than
I notice that NetBeans is warning me about using Thread.sleep() in a while loop
I want to create a thread for some db writes that should not block
Thread 1: is executing this loop while(running) { // Do Task() } println(Done); Thread
Here is the case of my Netbeans debugging question: I got a for loop
How do you limit the CPU of a while loop? In this case, the
Case Currently I'm working on database seeding script, executed with sqlcmd . For example
In my app i have a loop that move on array of UIImage and

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.