InitializeAsync() private method

Initializes the tracer, enabling all other operations on it.
All operations that require initialization will automatically perform it if it hasn't been performed already, so calling this method is never a requirement. However, since initialization can be potentially costly, calling it in advance at a more opportune moment can be preferable to lazy initialization.
private InitializeAsync ( CancellationToken cancellationToken = default(CancellationToken) ) : Task
cancellationToken System.Threading.CancellationToken
return Task
コード例 #1
0
        public async Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            Trace.Assert(UseCount > 0);
            await TaskUtilities.SwitchToBackgroundThread();

            await _tracer.InitializeAsync(cancellationToken);

            string fileName = null;

            try {
                fileName = Path.GetFileName(Location.FileName);
            } catch (ArgumentException) {
                return;
            }

            if (--UseCount == 0)
            {
                _tracer.RemoveBreakpoint(this);

                var code = $"rtvs:::remove_breakpoint({fileName.ToRStringLiteral()}, {Location.LineNumber})";
                try {
                    await Tracer.Session.ExecuteAsync(code, cancellationToken);
                } catch (RException ex) {
                    throw new InvalidOperationException(ex.Message, ex);
                }
            }
        }
コード例 #2
0
ファイル: RSessionExtensions.cs プロジェクト: Microsoft/RTVS
        /// <summary>
        /// Obtain an instance of <see cref="IRExecutionTracer"/> for the given <see cref="IRSession"/>.
        /// </summary>
        public static async Task<IRExecutionTracer> TraceExecutionAsync(this IRSession session, CancellationToken cancellationToken = default(CancellationToken)) {
            RExecutionTracer tracer;

            await _tracersSem.WaitAsync(cancellationToken).ConfigureAwait(false);
            try {
                if (!_tracers.TryGetValue(session, out tracer)) {
                    tracer = new RExecutionTracer(session);
                    await tracer.InitializeAsync(cancellationToken).ConfigureAwait(false);
                    _tracers.Add(session, tracer);
                }

                session.Disposed += Session_Disposed;
            } finally {
                _tracersSem.Release();
            }

            return tracer;
        }
コード例 #3
0
        /// <summary>
        /// Obtain an instance of <see cref="IRExecutionTracer"/> for the given <see cref="IRSession"/>.
        /// </summary>
        public static async Task <IRExecutionTracer> TraceExecutionAsync(this IRSession session, CancellationToken cancellationToken = default(CancellationToken))
        {
            RExecutionTracer tracer;

            await _tracersSem.WaitAsync(cancellationToken).ConfigureAwait(false);

            try {
                if (!_tracers.TryGetValue(session, out tracer))
                {
                    tracer = new RExecutionTracer(session);
                    await tracer.InitializeAsync(cancellationToken).ConfigureAwait(false);

                    _tracers.Add(session, tracer);
                }

                session.Disposed += Session_Disposed;
            } finally {
                _tracersSem.Release();
            }

            return(tracer);
        }