Dispose() public méthode

public Dispose ( ) : void
Résultat void
        public void StartCopying(string src, string dest)
        {
            CreateMissingDirs(src, dest);
            List <String>  dirFileList = GetFiles(src);
            FileAttributes attr        = File.GetAttributes(dest);

            if (!attr.HasFlag(FileAttributes.Directory))
            {
                return;
            }
            Directory.CreateDirectory(dest);

            foreach (var file in dirFileList)
            {
                string fileName = file.Replace(src, dest);

                _taskQueue.EnqueueTask(delegate {
                    try
                    {
                        File.Copy(file, fileName, true);
                        Interlocked.Increment(ref _copiedFiles);
                        Console.WriteLine("from: " + file + ", to: " + fileName + " by " + Thread.CurrentThread.Name);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                });
            }
            _taskQueue.Dispose();
            PrintCopiedFiles(ref _taskQueue.ThreadQueue);
        }
Exemple #2
0
        public IEnumerator <ITask> DropHandler(DsspDefaultDrop drop)
        {
            TaskQueue.Dispose();

            DefaultDropHandler(drop);
            yield break;
        }
 /// <summary>
 /// Close the WebSocketTransport
 /// </summary>
 /// <param name="disposing">Indicates whether disposal was initiated by <see cref="Dispose()"/> operation.</param>
 protected virtual void Dispose(bool disposing)
 {
     // Make sure any outstanding asynchronous read operation is cancelled.
     StopReading();
     _client?.Dispose();
     _socketQueue.Dispose();
 }
Exemple #4
0
 public override void Dispose()
 {
     LoggerExtensions.LogTrace(_logger, "Disposing", Array.Empty <object>());
     _queue.Dispose();
     base.Dispose();
     _delayedMessages?.Clear();
     _subscribers?.Clear();
 }
        public void DisposedShouldThrow()
        {
            var taskQueue = new TaskQueue();

            taskQueue.Dispose();

            Assert.ThrowsAsync <ObjectDisposedException>(() => taskQueue.Enqueue(() => DateTime.UtcNow)).Wait();
        }
 public void Dispose()
 {
     // Make sure any outstanding asynchronous read operation is cancelled.
     StopReading();
     _webSocket?.Dispose();
     _socketQueue?.Dispose();
     _readerCancellationSource?.Dispose();
 }
        public IEnumerator <ITask> DropHandler(DsspDefaultDrop drop)
        {
            // cancel any active tasks that are still active
            TaskQueue.Dispose();

            DefaultDropHandler(drop);
            yield break;
        }
Exemple #8
0
        protected void Dispose(bool disposing)
        {
            Trace.Call(disposing);

            if (disposing)
            {
                f_TaskQueue.Dispose();
            }
        }
        public async Task CanProcessEmptyQueue()
        {
            var queue = new TaskQueue();
            await Task.Delay(30);

            queue.Dispose();
            await Task.Delay(1);

            Assert.AreEqual(0, queue.Working);
        }
Exemple #10
0
        protected void Dispose(bool disposing)
        {
            Trace.Call(disposing);

            if (disposing)
            {
                f_TaskQueue.Dispose();
                _Session.Config.Changed -= _OnConfigChanged;
            }
        }
Exemple #11
0
        public async Task CanProcessEmptyQueue()
        {
            Log.MinimumLevel = LogLevel.Trace;
            var queue = new TaskQueue(loggerFactory: Log);
            await SystemClock.SleepAsync(30);

            queue.Dispose();
            await SystemClock.SleepAsync(1);

            Assert.Equal(0, queue.Working);
        }
Exemple #12
0
        protected void Dispose(bool disposing)
        {
            Trace.Call(disposing);

            if (disposing)
            {
                if (_LastSeenHighlightQueue != null)
                {
                    _LastSeenHighlightQueue.Dispose();
                }
                _LastSeenHighlightQueue = null;
            }
        }
Exemple #13
0
        public static TaskQueue StartNew(string name, string displayName, TaskQueueOptions options, IQueueStore queueStore)
        {
            var queue = new TaskQueue(name, displayName, options, queueStore);

            if (!_queues.TryAdd(name, queue))
            {
                queue.Dispose();
                throw new InvalidOperationException("Not able to add the queue to the pool.");
            }
            else
            {
                queue.Start();
            }

            return queue;
        }
Exemple #14
0
            public static void WaitAll(TaskDelegate[] delegates)
            {
                var taskQueue      = new TaskQueue();
                var delegatesCount = delegates.Length;
                var counter        = 0;

                for (var i = 0; i < delegates.Length; i++)
                {
                    delegates[i] = delegates[i] + (() => Interlocked.Increment(ref counter));
                    taskQueue.EnqueueTask(delegates[i]);
                }

                while (counter != delegatesCount)
                {
                    Thread.Yield();
                }
                taskQueue.Dispose();
            }
Exemple #15
0
        public static void DisconnectEngineFromGUI(bool cleanly)
        {
            Trace.Call(cleanly);

            IsDisconnecting = true;
            MainWindow.ChatViewManager.IsSensitive = false;
            if (cleanly)
            {
                try {
                    // sync tab positions
                    if (!IsLocalEngine && !UseLowBandwidthMode)
                    {
                        _MainWindow.Notebook.SyncPagePositions();
                    }

                    if (_FrontendManager != null)
                    {
                        _FrontendManager.IsFrontendDisconnecting = true;
                    }
                    if (_Session != null)
                    {
                        _Session.DeregisterFrontendUI(_MainWindow.UI);
                    }
                } catch (System.Net.Sockets.SocketException) {
                    // ignore as the connection is maybe already broken
                } catch (System.Runtime.Remoting.RemotingException) {
                    // ignore as the connection is maybe already broken
                }
            }
            if (_FrontendManagerCheckerQueue != null)
            {
                _FrontendManagerCheckerQueue.Dispose();
            }
            _MainWindow.ChatViewManager.Clear();
            _MainWindow.UpdateProgressBar();
            // make sure no stray SSH tunnel leaves behind
            _MainWindow.EngineManager.Disconnect();
            _MainWindow.NetworkStatus = null;
            _MainWindow.Status        = _("Disconnected from engine.");

            _FrontendManager = null;
            Session          = null;
            IsDisconnecting  = false;
        }
Exemple #16
0
        protected void Dispose(bool disposing)
        {
            Trace.Call(disposing);

            if (disposing)
            {
                if (_LastSeenHighlightQueue != null)
                {
                    _LastSeenHighlightQueue.Dispose();
                }
                _LastSeenHighlightQueue = null;

                // HACK: this shouldn't be needed but GTK# keeps GC handles
                // these callbacks for some reason and thus leaks :(
                _OutputMessageTextView.Dispose();
                CloseItem.Activated -= OnTabMenuCloseActivated;
                _OutputScrolledWindow.Vadjustment.ValueChanged -= OnVadjustmentValueChanged;
            }
        }
 public void Dispose()
 {
     _timer?.Dispose();
     _taskQueue?.Dispose();
 }
 public void Dispose()
 {
     _analyzer.AnalysisComplete -= OnAnalysisComplete;
     _taskQueue.Dispose();
 }
Exemple #19
0
 public virtual void Dispose()
 {
     StopAsync().WaitAndUnwrapException();
     _taskQueue?.Dispose();
 }
 /// <inheritdoc/>
 public void Dispose()
 {
     _client?.Dispose();
     _readerCancellationSource?.Dispose();
     _socketQueue?.Dispose();
 }
Exemple #21
0
 public void Dispose() => _queue?.Dispose();