when working with bulk volume system getting slow by c# window service
<p>here below i have pasted a c# code which i was using threading methodology in window service, on service initial time it was working proper after some process goin on the system was getting slow, some times i am recieving errors like system time out memory exeception kind of errors.</p>

<p>can any one suggest me whether my threading methodology is good or not? kindly suggest some suggestion</p>

<p>i m using timer event to it will fire for every three minutes --> (DueTime)</p>

<p>(CsvGenFromDatabase) --> this the method which i was calling in on start method , it will calls some sub methods in this </p>

<pre><code> protected override void OnStart(string[] args)
    {



            strNowDate = DateTime.Now.ToLongTimeString();

            timerjob.Elapsed += new ElapsedEventHandler(CsvGenFromDatabase);

            timerjob.Interval = Convert.ToDouble(DueTime);

            timerjob.Enabled = true;

            eventLog1.WriteEntry("my service started");

    }


 protected override void OnStop()
    {

            strNowDate = DateTime.Now.ToLongTimeString();
            eventLog1.WriteEntry("my service stopped");

    }

private void CsvGenFromDatabase(object sender, EventArgs e)
    {


            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) // Transaction Scope Started
            {

                Thread threadITD = new Thread(new ThreadStart(FileGenerationForITD));  // Thread Initialize for ITD 


                Thread threadCTD = new Thread(new ThreadStart(FileGenerationForCTD));  // Thread Initialize for CTD 


                Thread threadCID = new Thread(new ThreadStart(FileGenerationForCID));  // Thread Initialize for CID 


                Thread threadFFM = new Thread(new ThreadStart(FileGenerationForFFM));  // Thread Initialize for FFM



                try
                {
                    if ((threadITD == null) || (threadITD.ThreadState == System.Threading.ThreadState.Stopped) || (threadITD.ThreadState == System.Threading.ThreadState.Unstarted))
                    {
                        threadITD.Start();  // Thread Started for ITD 
                        //LogError(1, "Form1", "CsvGenFromDatabase", "ITD Thread Started", "ITD Thread Started");
                    }
                    if ((threadCTD == null) || (threadCTD.ThreadState == System.Threading.ThreadState.Stopped) || (threadCTD.ThreadState == System.Threading.ThreadState.Unstarted))
                    {
                        threadCTD.Start(); // Thread Started for CTD 
                       // LogError(1, "Form1", "CsvGenFromDatabase", "CTD Thread Started", "CTD Thread Started");
                    }
                    if ((threadCID == null) || (threadCID.ThreadState == System.Threading.ThreadState.Stopped) || (threadCID.ThreadState == System.Threading.ThreadState.Unstarted))
                    {
                        threadCID.Start(); // Thread Started for CID 
                       // LogError(1, "Form1", "CsvGenFromDatabase", "CID Thread Started", "CID Thread Started");
                    }
                    if ((threadFFM == null) || (threadFFM.ThreadState == System.Threading.ThreadState.Stopped) || (threadFFM.ThreadState == System.Threading.ThreadState.Unstarted))
                    {
                        threadFFM.Start(); // Thread Started for FFM
                        //LogError(1, "Form1", "CsvGenFromDatabase", "FFM Thread Started", "FFM Thread Started");
                    }

                }
                catch (Exception ex)
                {
                    objErrorLog.SrtErrorText = ex.ToString().Substring(0, 25);
                    objErrorLog.StrErrorDescription = ex.ToString();
                    objErrorLog.WriteErrorLog(objErrorLog);
                }
                finally
                {
                    scope.Complete();

                }
            }


    }
</code></pre>
