Esempio n. 1
0
 private static void Insert()
 {
     while (true)
     {
         lock (CacheCollection)
         {
             for (int i = 0; i < CacheCollection.Count(); i++)
             {
                 var person = CacheCollection[i];
                 if (!person.HasProcessed)
                 {
                     lock (myConnection)
                     {
                         Thread.Sleep(1200);
                         myConnection.Open();
                         var          strInsertSQL = "INSERT INTO `person` (`Id`,`Name`) VALUES ('" + person.Id + "', '" + person.Name + "')";
                         MySqlCommand cmdInserttblProductFrance = new MySqlCommand(strInsertSQL, myConnection);
                         cmdInserttblProductFrance.ExecuteNonQuery();
                         CloseConnection();
                         person.HasProcessed = true;
                     }
                 }
             }
         }
         CacheCollection.Clear();
     }
 }