title: C# reading Database on Timer
body: <p>I'm reading MSSQL database on every 10 minute and processing the data &amp; uploading XML file generated from given data. Database is updated at every 8 minute at public domain. With in every timer call we receive around 1050-2000 data rows. Currently i'm using C# Timer to get and update and sync both local and remote database. Sometime the following code get unresponsive and hang-in between. Please provide the alternative for the following or any other logic that will work well in real time.</p>
  
  <p>Code:</p>
  
  <pre><code>    System.Timers.Timer Timer =null;
  
      public void initModelViewer
      {
          Timer = new System.Timers.Timer();
          Timer.Interval = 1000*60*10;
          Timer.Enabled = true;    
          Timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
          Timer.Start();
      }
  
  
      void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
      {
         try
        {
            lock (this)
          {
              #region GetCustIRDI
              DataSet DsIRDIModel = DbManager.GetDatasetByCommand(cSQL.getIRDIInfo("SQL Command"));
              //Process the information.
              //update the client side application.
              #endregion
  
              #region GetCustIRDIXML
              DataSet DsIRDIXMLModel = DbManager.GetDatasetByCommand(cSQL.getIRDIXML("SQL Command"));
  
              //Generate and save the XML. Another app upload it
              XMLAPPFabicModel FabricXML = new XMLAPPFabicModel(DsIRDIXMLModel, XMLSpecs.Limitation));
  
              //Fabric EventHandlers...
  
              //Sync the local DBFabricModel and update main server
              #endregion
          }
  }catch(Exception ex){
   //Error handling 
  }
  
  
      }
  </code></pre>