Ejemplo n.º 1
0
        private static async Task <IAsyncQuickInfoSession> StartQuickInfoSessionAsync(AsyncQuickInfoSession session, CancellationToken cancellationToken)
        {
            try
            {
                await session.UpdateAsync(allowUpdate : false, cancellationToken : cancellationToken).ConfigureAwait(false);
            }
            catch (OperationCanceledException) when(!cancellationToken.IsCancellationRequested)
            {
                // Don't throw OperationCanceledException unless the caller canceled us.
                // This can happen if computation was canceled by a quick info source
                // dismissing the session during computation, which we want to consider
                // more of a 'N/A' than an error.
                return(null);
            }

            return(session.State == QuickInfoSessionState.Dismissed ? null : session);
        }