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 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 514k
  • Answers 514k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Since your current callbacks look very similar, you can make… May 16, 2026 at 6:10 pm
  • Editorial Team
    Editorial Team added an answer OpenID, One Year Later on SO blog explains how do… May 16, 2026 at 6:10 pm
  • Editorial Team
    Editorial Team added an answer Ok, so there is no real way to do this… May 16, 2026 at 6:10 pm

Trending Tags

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

Top Members

Related Questions

i wonder which installation to use for my php? i will be using apache.
I'm currently using Retlang for message-based multithreading in .NET, which is a great library.
The requirement of the TCP server: receive from each client and send result back
I am a beginner in C# and I want to do the following: Thread
I have main thread which calls another thread. timeout period of second one is
I have a simple thread pool written in pthreads implemented using a pool of
I am designing a server in java which would be used to trade bonds.
If you read this thread before - forget everything I wrote , I must
Here's what I'm trying to solve: My class (which could be hosted by an
Hey, so I'm trying to build a simple lan game using sockets (not tcpclient

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.