コード例 #1
0
        public static void RunAndForget(this IProjectThreadingService threadingService, Func <Task> asyncAction, ConfiguredProject configuredProject, ProjectFaultSeverity faultSeverity = ProjectFaultSeverity.Recoverable, ForkOptions options = ForkOptions.Default)
        {
            Requires.NotNull(threadingService, nameof(threadingService));

            // If you do not pass in a project it is not legal to ask the threading service to cancel this operation on project unloading
            if (configuredProject is null)
            {
                options &= ~ForkOptions.CancelOnUnload;
            }

            threadingService.Fork(asyncAction, factory: null, configuredProject: configuredProject, watsonReportSettings: s_defaultReportSettings, faultSeverity: faultSeverity, options: options);
        }
コード例 #2
0
        private void WriteLineCore(string text)
        {
            // Extremely naive implementation of a Windows Pane logger - the assumption here is that text is rarely written,
            // so transitions to the UI thread are uncommon and are fire and forget. If we start writing to this a lot (such
            // as via build), then we'll need to implement a better queueing mechanism.
            _threadingService.Fork(async() => {
                IVsOutputWindowPane pane = await _outputWindowProvider.GetOutputWindowPaneAsync()
                                           .ConfigureAwait(true);

                pane.OutputStringNoPump(text + Environment.NewLine);
            }, options: ForkOptions.HideLocks | ForkOptions.StartOnMainThread);
        }
コード例 #3
0
        public void WriteLine(StringFormat format)
        {
            if (IsEnabled)
            {
                string text = format.Text + Environment.NewLine;

                // Extremely naive implementation of a Windows Pane logger - the assumption here is that text is rarely written,
                // so transitions to the UI thread are uncommon and are fire and forget. If we start writing to this a lot (such
                // as via build), then we'll need to implement a better queueing mechanism.
                _threadingService.Fork(async() =>
                {
                    IVsOutputWindowPane pane = await _outputWindowProvider.GetOutputWindowPaneAsync();

                    pane.OutputStringNoPump(text);
                }, options: ForkOptions.HideLocks | ForkOptions.StartOnMainThread,
                                       factory: _threadingService.JoinableTaskFactory);
            }
        }
コード例 #4
0
        /// <summary>
        ///     Executes the specified delegate in a safe fire-and-forget manner, prevent the project from
        ///     closing until it has completed.
        /// </summary>
        /// <param name="threadingService">
        ///     The <see cref="IProjectThreadingService"/> that handles the fork.
        /// </param>
        /// <param name="asyncAction">
        ///     The async delegate to invoke. It is invoked asynchronously with respect to the caller.
        /// </param>
        /// <param name="configuredProject">
        ///     The configured project which the delegate operates on, if applicable. Can be <see langword="null"/>.
        /// </param>
        /// <param name="faultSeverity">
        ///     Suggests to the user how severe the fault is if the delegate throws.
        /// </param>
        /// <param name="options">
        ///     Influences the environment in which the delegate is executed.
        /// </param>
        public static void RunAndForget(this IProjectThreadingService threadingService, Func <Task> asyncAction, ConfiguredProject configuredProject, ProjectFaultSeverity faultSeverity = ProjectFaultSeverity.Recoverable, ForkOptions options = ForkOptions.Default)
        {
            Requires.NotNull(threadingService, nameof(threadingService));

            threadingService.Fork(asyncAction, factory: null, configuredProject: configuredProject, watsonReportSettings: s_defaultReportSettings, faultSeverity: faultSeverity, options: options);
        }