示例#1
0
        internal void Start()
        {
            Importer = new FileImporter(ImportFileInfo);
            Importer.SetLogger(_logger);

            ImportThread = new Thread(() =>
            {
                try
                {
                    Importer.Process();
                }catch (Exception ex)
                {
                    Log("!!!!Error nell'importazione di " + ImportFileInfo);
                    Log(ex.ToString());
                }
                finally
                {
                    if (OnTerminate != null)
                    {
                        OnTerminate(this, ImportFileInfo);
                    }
                }
            });

            ImportThread.Start();
        }
示例#2
0
        private void StartProcess(ImportFileInfo file)
        {
            file.MoveToFolder(ServiceConfiguration.Instance.StagingFilePath);

            //Log("Sposto il file in " + stagingFilePath);

            var importer = new FileImporter(file);

            importer.SetLogger(_logger);

            var processingThread = new Thread(() =>
            {
                try
                {
                    importer.Import();
                }catch (Exception ex)
                {
                    Log("Errore su thread");
                }
                finally
                {
                    lock (_lock)
                    {
                        _numRunningThreads--;
                        _companyRegistry.Remove(file.Company);
                    }

                    //Interlocked.Decrement(ref _numRunningThreads);

                    LogThreads();
                }
            });

            lock (_lock)
            {
                _numRunningThreads++;
                _companyRegistry.Add(file.Company);
            }

            //Interlocked.Increment(ref _numRunningThreads);


            processingThread.Start();
        }