Hi Experts,
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 { }
}