Exemplo n.º 1
0
        protected void UpdateDataTimely()
        {
            string logPath = ConfigurationManager.AppSettings["LogFilePath"];

            try
            {
                DBOperation.InsertDataToDB();
                DBOperation.CheckDBUpdate();
            }
            catch (Exception e)
            {
                System.IO.StreamWriter file = new System.IO.StreamWriter(logPath, true);
                file.WriteLine("Exception at: " + DateTime.Now.ToString());
                file.WriteLine(e.Message);
                file.Close();
            }
            finally
            {
                Task.Delay(1000 * 60 * 20).ContinueWith(_ =>
                {
                    UpdateDataTimely();
                });
            }
        }