コード例 #1
0
        /// <summary>
        /// Stop all writing to this class.
        /// Once stopped, it cannot be resumed.
        /// All data is then immediately flushed to the output.
        /// This method calls Dispose()
        /// </summary>
        /// <returns>the transaction number of the last point that written</returns>
        public long Stop()
        {
            Log.Publish(MessageLevel.Info, "Stop() called", "Write is stopping");

            lock (m_syncRoot)
            {
                m_stopped = true;
            }
            m_rolloverTask.Dispose(); //This method block until the worker runs one last time
            Dispose();
            return(m_latestTransactionId);
        }
コード例 #2
0
        /// <summary>
        /// Stop all writing to this class.
        /// Once stopped, it cannot be resumed.
        /// All data is then immediately flushed to the output.
        /// This method calls Dispose()
        /// </summary>
        /// <returns></returns>
        public long Stop()
        {
            Log.Publish(MessageLevel.Info, "Stop() called", "Write is stopping");

            lock (m_syncRoot)
            {
                m_stopped = true;
            }
            m_rolloverTask.Dispose();
            Dispose();
            return(m_lastCommitedSequenceNumber);
        }
コード例 #3
0
 /// <summary>
 /// Attempts to disconnect from data input source.
 /// </summary>
 protected override void AttemptDisconnection()
 {
     if ((object)m_timer != null)
     {
         m_timer.Dispose();
         m_timer = null;
     }
     if ((object)m_statusUpdate != null)
     {
         m_statusUpdate.Dispose();
         m_statusUpdate = null;
     }
 }
コード例 #4
0
        public void Dispose_Success()
        {
            DateTimeOffset now  = new DateTimeOffset(2013, 6, 1, 12, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset now2 = new DateTimeOffset(2013, 6, 1, 12, 0, 1, 0, TimeSpan.Zero);
            ScheduledTask <FailableScheduledAction> task = new ScheduledTask <FailableScheduledAction>(Schedule.CreateOneTime(now), new FailableScheduledAction(FailableScheduledAction.DummyAction.Run), true, now, now2);

            task.Dispose();

            CustomAssert.ThrowsException <ObjectDisposedException>(() =>
            {
                FailableScheduledAction action = task.Action;
            });

            task.Dispose();
        }
コード例 #5
0
 public void Dispose()
 {
     m_disposing = true;
     Thread.MemoryBarrier();
     m_syncEvent.Dispose();
     m_async.Dispose();
 }
コード例 #6
0
ファイル: LoggerInternal.cs プロジェクト: xj0229/gsf
        /// <summary>
        /// Gracefully terminate all message routing. Function blocks until all termination is successful.
        /// </summary>
        public void Dispose()
        {
            if (m_disposing)
            {
                return;
            }

            lock (m_syncRoot)
            {
                //Ensure that setting disposing is in a synchronized context.
                m_disposing = true;
            }

            //These scheduled tasks block when dispose is called. Therefore do not put these in a lock on the base class.
            m_calculateRoutingTable.Dispose();
            m_routingTask.Dispose();

            lock (m_syncRoot)
            {
                m_allPublishers.Clear();
                foreach (var sub in m_subscribers)
                {
                    (sub.Target as LogSubscriberInternal)?.Dispose();
                }
                m_subscribers.Clear();
            }
        }
コード例 #7
0
ファイル: ScheduledTaskTest.cs プロジェクト: xj0229/gsf
 public void TestMethod1()
 {
     m_task          = new ScheduledTask(ThreadingMode.DedicatedBackground, ThreadPriority.Highest);
     m_task.Running += task_Running;
     m_task.Start(10);
     Thread.Sleep(1000);
     m_task.Dispose();
     System.Console.WriteLine("Disposed");
 }
コード例 #8
0
        /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
        /// <filterpriority>2</filterpriority>
        public void Dispose()
        {
            m_flushTask.Dispose();
            lock (m_syncRoot)
            {
                if (m_writer != null)
                {
                    string fileName = m_writer.FileName;
                    m_writer.Dispose();
                    m_writer = null;

                    OnNewFileComplete(fileName);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="LogSourceBase"/> object and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (!m_disposed)
            {
                m_disposed = true;

                if (disposing)
                {
                    if (m_rolloverTask != null)
                    {
                        m_rolloverTask.Dispose();
                    }
                    m_rolloverTask = null;
                }
            }
            base.Dispose(disposing);
        }
コード例 #10
0
 /// <summary>
 /// Releases the unmanaged resources used by the <see cref="LogSourceBase"/> object and optionally releases the managed resources.
 /// </summary>
 /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
 protected override void Dispose(bool disposing)
 {
     if (!m_disposed && disposing)
     {
         ReleaseClientResources();
         m_processRemovals.Dispose();
         m_listLog.Dispose();
         lock (m_syncRoot)
         {
             foreach (ArchiveTableSummary <TKey, TValue> f in m_fileSummaries.Values)
             {
                 f.SortedTreeTable.BaseFile.Dispose();
             }
         }
         m_disposed = true;
     }
     base.Dispose(disposing);
 }
コード例 #11
0
        public void IsTaskDue_False_Success()
        {
            ScheduledTask <FailableScheduledAction> task = new ScheduledTask <FailableScheduledAction>(Schedule.CreateOneTime(DateTimeOffset.Now.AddMinutes(-1.0)), new FailableScheduledAction(FailableScheduledAction.DummyAction.ThrowException), true, null, null);

            task.IsEnabled = false;
            Assert.IsFalse(task.IsTaskDue);
            task.IsEnabled = true;

            task.IsScheduled = true;
            Assert.IsFalse(task.IsTaskDue);
            task.IsScheduled = false;

            task.Dispose();
            Assert.IsFalse(task.IsTaskDue);

            task = new ScheduledTask <FailableScheduledAction>();
            Assert.IsFalse(task.IsTaskDue);
        }
コード例 #12
0
 public void Dispose()
 {
     m_worker.Dispose();
 }