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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:41:06+00:00 2026-05-11T22:41:06+00:00

I am using thread which will receive messages from the external application.So my thread

  • 0

I am using thread which will receive messages from the
external application.So my thread shud be alive always.

I want my thread to be running through out the application,
untill application exits. Currently i am calling my thread in program.cs,
which is the startup for windows application c#. Please see the code below
to know how i am doing it.

When i use the below code, the thread starts up when
application starts…But it aborts some how, after the thread recieves
one message from the external application.

I hope i am clear with my questio. Please help. Thanks.


  static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        StartThread();
        Application.Run(new Screensaver());
    }
    public static void StartThread()
    {
            DeamonEngine Deamon = new DeamonEngine();
            Thread ThreadReciever = new Thread(Deamon.Receiver);
            if (!(ThreadReciever.IsAlive))
            {
                ThreadReciever.Start();
            }
        }
    }

From a comment:

    void Receiver() { 
        try { 
            Initiate socket s; 
            Bind Ip address; 
            s.Receiver[bytes]; 
            Access the members of message received in bytes;
            Assign the members of message to local variable;
            Read Xml File, get the node values and write to batch file; 
            Execute batch file. 
        } 
        catch { } 
    }
  • 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-11T22:41:06+00:00Added an answer on May 11, 2026 at 10:41 pm

    Having a thread execute the Receiver method doesn’t mean the thread will repeatedly execute the method.

    Given the processing code in the question, Daemon.Receiver needs to execute in a loop so that it can go back and retrieve the next message to process. It should look something like this:

    void Receiver() { 
        while(!done) // without this loop, only one execution will occur
        {
            try { 
                // do stuff
            } 
            catch { 
                // log/handle error
            } 
    
            // wait for next message
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 312k
  • Answers 312k
  • 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
  • Editorial Team
    Editorial Team added an answer Uh, I got it: After debugging the hibernate code, I… May 13, 2026 at 10:37 pm
  • Editorial Team
    Editorial Team added an answer This site has information about the Google Safe Browsing API,… May 13, 2026 at 10:37 pm
  • Editorial Team
    Editorial Team added an answer Unfortunately there is no concept of a variable in a… May 13, 2026 at 10:37 pm

Related Questions

I am designing a server in java which would be used to trade bonds.
As a side project I'm currently writing a server for an age-old game I
Let me first say that I have quite a lot of Java experience, but
I am building an ASP.NET website which will collect data from a user and

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.