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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:12:47+00:00 2026-06-05T02:12:47+00:00

Can someone explain this code to me a little so I have a firmer

  • 0

Can someone explain this code to me a little so I have a firmer grasp of exactly what is going on in it?

taskWrapper = XTThreadPool.DEFAULT_POOL.Run((System.Threading.ThreadStart)delegate()
{
    //Remote procedure execution and result processing code.
    //Some vars set in here are used after the Join() below.
}, true, true);

while (taskWrapper.Status == XTThreadPool.Task.STATUS.None)
{
    System.Threading.Thread.Sleep(10);
}

...

taskWrapper.Join();

It looks to me like a separate thread is being created and the remote procedure call is used within it. I’m a little hazy about the use of the delegate or the syntax of the taskWrapper object creation though.

  • 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-05T02:12:49+00:00Added an answer on June 5, 2026 at 2:12 am

    Well it’s a little tricky without knowing what’s in the XTThreadPool class, but you could have a guess…

    The chances are that this first bit…

    taskWrapper = XTThreadPool.DEFAULT_POOL.Run((System.Threading.ThreadStart)delegate()
    {
        //Remote procedure execution and result processing code.
        //Some vars set in here are used after the Join() below.
    }, true, true);
    

    …starts a thread running asynchronously and passes the method specified in the section where you’ve put comments. This is probably achieved by creating an instance of a Thread passing the method as a delegate to its constructor, and calling newThread.Start(), which starts execution on a new thread inside the application’s thread pool. The thread reference can then be used to check the status of that thread and see if it’s completed or not, which is probably what this section does:

    while (taskWrapper.Status == XTThreadPool.Task.STATUS.None)
    {
        System.Threading.Thread.Sleep(10);
    }
    

    This seems a bit strange to me. System.Threading.Thread accesses the current thread, not the thread started by the thread pool, and the Sleep method just means “do nothing”. So the current thread is waiting for the thread started by the taskWrapper instance to enter a status other than None. Now this is where it gets difficult because we don’t really know what taskWrapper is doing.

    It is possible that actually it’s just waiting for the thread to complete execution, but then there would be no point having a separate thread, because the work might as well be done in place of the while loop above.

    And then this:

    taskWrapper.Join();
    

    The line above could really do anything, like I say it depends on the implementation of whatever taskWrapper is. But based on the name I would guess it uses the the Thread.Join method, which basically causes the calling thread (this thread) to wait until the thread it’s called on (taskWrapper) has completed. However taskWrapper itself is not actually be a thread (based on the check for the value of the Status property above), more likely it’s just a wrapper around the thread.

    I’ve completely guessed at this to be honest, it really could be doing anything. Without seeing the code for the XTThreadPool class and whatever DEFAULT_POOL is an instance of it’s going to be impossible to know for sure what’s happening.

    On first inspection, if the code is doing what I’ve guessed above there is no point having another thread to do the work and no point having the while loop! The whole thing could be replaced with whatever’s in the method inside the call to Run.

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

Sidebar

Related Questions

Possible Duplicate: Can someone Explain this jQuery code? I have posted this before, but
I am newbie to jQuery, can someone explain what this code does: $(#currency form).submit(function(e)
Can someone explain to me what the bolded portions of this code are doing?
Can someone write some sample code to explain this concept? I know what a
I am very confused with this kind of casting. Can someone explain what exactly
Maybe I'm a little behind the eight ball. Hopefully someone can explain this. I
Can someone explain this code please? how is it that the function bar accepts
Can someone explain why this code: import sys sys.path.append(C:\\WINDOWS\\system32) import clr clr.AddReferenceToFile(wiimotelib.dll) works fine
Can someone explain what this piece of code does. what is the test function
Can someone explain to me why this code prints 14? I was just asked

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.