I have created a
windows service in
C# with WiX application to send data to the server automatically. So, I have used
thread for capturing and sending the data to the server. Below is my code.
protected override void OnStart(string[] args)
{
trd = new Thread(new ThreadStart(ThreadTask));
trd.IsBackground = true;
trd.Name = "My Worker Thread";
trd.Start();
}
public void ThreadTask()
{
while (true)
{
SendData();
Thread.Sleep(3000);
}
}
public void SendData()
{
}
I am using
HttpWebRequest for data sending. This application is able to send the data to the server in
Debug mode, but as soon as I run this application normally after building the setup
.msi file through WiX, the Windows Service gets started normally but the application does not send the data. Whereas I have also tested that the thread is running fine through service when I put a simple file write in the thread inside a function under OnStart method.
Is it a matter of week internet or something else is happening. At one hand the Service is running well, on the other hand
data is successfully sent in Debug mode, only that
without Debug,
data is not sent through Service. Please help me get through this as soon as possible.
Any kind of help will be highly appreciated.
Thanks in advance.