Ejemplo n.º 1
0
        public void Init()
        {
            var sw = Stopwatch.StartNew();

            if (!Directory.Exists(pathLocalFolder))
            {
                logger.Info("Repository", "Create local note folder: " + pathLocalFolder);
                Directory.CreateDirectory(pathLocalFolder);
            }

            LoadNotesFromLocal();

            thread.Start(appconfig.GetSyncDelay());

            rawFilesystemRepo.Start();

            logger.Trace("Repository", $"SyncThread init took {sw.ElapsedMilliseconds}ms");
        }
Ejemplo n.º 2
0
        private void ThreadRun()
        {
            running = true;

            for (; ;)
            {
                lock (_syncobj)
                {
                    isSyncing = true;
                    {
                        _comChannel.Reset();
                        DoSync();
                    }
                    isSyncing = false;
                }

                var tick = Environment.TickCount;
                do
                {
                    if (cancel)
                    {
                        running = false; _log.Info("Sync", "Thread cancelled"); return;
                    }
                    if (prioritysync)
                    {
                        prioritysync = false; _log.Info("Sync", "Thread ffwd (priority sync)"); break;
                    }

                    _comChannel.WaitOne(10 * 1000);                     // 10 sec
                } while (Environment.TickCount - tick < delay);
            }
        }