예제 #1
0
        private void RunTask()
        {
            try
            {
                lock (this)
                {
                    if (currentTask == null)
                    {
                        currentTask = DatabaseTask.Create();
                    }
                    else
                    {
                        LogText("Previous backup is still running", EventLogEntryType.Information);
                        return;
                    }
                }



                currentTask.Run();
                LogText("Task completed successfully", EventLogEntryType.Information);
                lock (this) {
                    currentTask = null;
                }
            }
            catch (Exception ex)
            {
                LogText(ex.ToString(), EventLogEntryType.Error);
            }
            finally {
                lock (this)
                {
                    currentTask = null;
                }
            }
        }