Firstly is this your service start function?
-
public void Start()
-
{
-
Status_Event(status_begin, "Queue Thread Begin") ;
-
stopped = false ;
-
-
while (true)
-
{
-
Thread.Sleep(100) ;
-
Start_QueueProcess() ;
-
if (stopped) break ;
-
}
-
....
-
I don't see any timers being used... You can use system.timers.timer or threading timer for services...
You mentioned that you, "
process files....form folder.. into database...further to process the data . " Can you explain more here... perhaps the exact procedure?
Problems that i can guess:
* Ownership of file can be a problem....for e.g. the service is trying access a file that is locked or being used by another process...
* You are also connecting to database? connection times out? DB not available...
* You should also check for Deadlocks....
This code is fairly wrong.... (especially from a service point of view )
- while (true)
-
{
-
Thread.Sleep(100) ;
-
Start_QueueProcess() ;
-
if (stopped) break ;
-
}
-
Possible solutions:
* If you intent to call Start_QueueProcess(), periodically you need to use system.timers.timer, in case of service...
* Also you must consider using threads or better asynchronous programming so that you windows service doesn't hang....
* Make sure your service start returns immediately .... Create a separate thread if needed to execute any function....
* Lock your functions so that only one instance of function is executing....
* Periodically do ...
-
GC.Collect();
-
GC.WaitForPendingFinalizers();
-
GC.Collect();
-
* Write exception to a log file/ Event log