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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:34:07+00:00 2026-05-11T01:34:07+00:00

We have taken over some .NET 1.1 Windows Service code that spawns threads to

  • 0

We have taken over some .NET 1.1 Windows Service code that spawns threads to read messages off a queue (SeeBeyond eGate JMS queue, but that is not important) and in turn spawns threads to process the message in the target application service. We are continually encountering logic and design decisions that is puzzling us to no end. Here is one example, where the message (lsMessage) has been retrieved from the queue and ready for processing

if(lsMessage != null) {     // Initialize a new thread class instance, pass in message     WorkerThread worker = new WorkerThread(lsMessage);  Process:     // Start a new thread to process the message     Thread targetWorker = new Thread(new ThreadStart(worker.ProcessMessage));     if(targetWorker != null)     {         targetWorker.Priority = ThreadPriority.Highest;         targetWorker.Name = 'Worker ' + queueKey.ToString();         targetWorker.Start();          // wait for worker thread to join back in specified period         bool isFinished = targetWorker.Join(SYNC_THREAD_TIMEOUT);          string message = worker.replyMsg;          if ( !isFinished )  // BF is timeout         {             targetWorker.Abort();              // [obscure developer name] 25/10/2004: calling Join() to wait for thread to terminate.             // for EAI listener threads problem, ensure no new thread is started              // before the old one ends             targetWorker.Join();              // prepare reply message             string errorMsg = string.Format('EAIMsg {0}: BF is timeout. Send sync message back to caller.', worker.messageKey);             log.Debug(errorMsg);              message = worker.GenErrorCode(message, errorMsg);         }          // Commit message         MQ.ReceiverCommit(queueKey, worker.messageKey, false);          // Send back the response to the caller         MQ.RespondSend(queueKey, message);      }      else      {         log.Debug(string.Format('Fail to start worker thread to process sync message. Thread returned is null. Sleep for {0} milliseconds.', LIMIT_RESOURCE_SLEEP));         Thread.Sleep(LIMIT_RESOURCE_SLEEP);         goto Process;     } } 

Please ignore the use of label and goto for the moment; that is not the question. Our bewilderment is the check whether the Thread object is null right after instantiation. The else statement below seems to suggest the previous developers have encountered situations like this before. Of course, the original developers are long gone. So we would like to know, can the CLR really instantiate an object after the call to the constructor and return a null? We have no knowledge of such a possibility.

  • 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. 2026-05-11T01:34:07+00:00Added an answer on May 11, 2026 at 1:34 am

    In my opinion, what the else statement suggests is that the previous developers didn’t know their C#. A constructor always returns a constructed object or throws an exception.

    In the very old times, C++ constructors could return null, so maybe the problem comes from that. This is no longer true in C++ either, at least for the default new operator.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer First of all, I think it might be easier to… May 11, 2026 at 1:15 pm
  • added an answer A direct conversion from ANSI to ASCII might not always… May 11, 2026 at 1:15 pm
  • added an answer Since one div is initially hidden, you can simply call… May 11, 2026 at 1:15 pm

Related Questions

No related questions found

Trending Tags

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

Top Members

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.