コード例 #1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Task DisposeAction() => Task.Factory.StartNew(() =>
                {
                    Trace.WriteLine("Running dispose task");
                    SchedulerRunCancellationTokenSource.Cancel();
                }, CancellationToken.None,
                                                              TaskCreationOptions.None,
                                                              ProxyScheduler.AsTplScheduler());

                var disposeTask = postToScheduler(DisposeAction);

                disposeTask.Wait();

                m_postOnCallStack.Dispose();
            }
        }
コード例 #2
0
        protected override void Dispose(bool disposing)
        {
            try
            {
                m_ignoreCancellationToken.Value = true;
                SchedulerRunCancellationTokenSource.Cancel();
                QueueTasksResult result;
                do
                {
                    result = QueueTasksToInnerScheduler();
                    result.WhenAllTask.Wait();
                } while (result.HasMoreTasks);
            }
            finally
            {
                m_ignoreCancellationToken.Value = false;
            }

            m_ignoreCancellationToken.Dispose();
        }
コード例 #3
0
        public void Dispose()
        {
            lock (m_serviceLockObject)
            {
                if (m_disposed)
                {
                    return;
                }

                try
                {
                    Dispose(true);
                    m_disposed = true;
                    m_serviceCompleteTcs.TrySetResult(null);
                    SchedulerRunCancellationTokenSource.Cancel();
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                    m_serviceCompleteTcs.TrySetException(ex);
                }
            }
        }