IVsTask IVsTaskSchedulerService.CreateTaskEx(uint context, uint options, IVsTaskBody taskBody, object asyncState)
 {
     return new VsTask(this, (VsTaskRunContext)context, () =>
     {
         object result;
         taskBody.DoWork(null, 0, null, out result);
         return result;
     });
 }
Exemplo n.º 2
0
 IVsTask IVsTaskSchedulerService.CreateTaskEx(uint context, uint options, IVsTaskBody taskBody, object asyncState)
 {
     return(new VsTask(this, (VsTaskRunContext)context, () =>
     {
         object result;
         taskBody.DoWork(null, 0, null, out result);
         return result;
     }));
 }
Exemplo n.º 3
0
            public IVsTask ContinueWithEx(uint context, uint options, IVsTaskBody taskBody, object asyncState)
            {
                VsTask continuation = new VsTask(this.owner, (VsTaskRunContext)context, () =>
                {
                    object taskBodyResult;
                    taskBody.DoWork(null, 0, null, out taskBodyResult);
                    return(taskBodyResult);
                });

                continuation.Start();
                return(continuation);
            }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MockVSTask"/> class.
        /// </summary>
        /// <param name="vsTaskSchedulerService2">The <see cref="SVsTaskSchedulerService"/>.</param>
        /// <param name="context">The scheduling option for this task.</param>
        /// <param name="taskBody">The body to execute.</param>
        /// <param name="asyncState">The async state object to store.</param>
        public MockVSTask(IVsTaskSchedulerService2 vsTaskSchedulerService2, uint context, IVsTaskBody taskBody, object?asyncState = null)
        {
            this.vsTaskSchedulerService2 = vsTaskSchedulerService2 ?? throw new ArgumentNullException(nameof(vsTaskSchedulerService2));
            this.context = context;
            this.task    = new Task <object>(
                () =>
            {
                taskBody.DoWork(this, 0, Array.Empty <IVsTask>(), out object result);
                return(result);
            },
                this.cancellationTokenSource.Token);

            this.asyncState = asyncState;
        }
Exemplo n.º 5
0
 /// <inheritdoc />
 public IVsTask ContinueWithEx(uint context, uint options, IVsTaskBody pTaskBody, object?pAsyncState)
 {
     // NOTE: We ignore options (and context), if any tests are testing code that relies on either this
     // would need to be modified to properly support them.
     return(new MockVSTask(
                this.vsTaskSchedulerService2,
                context,
                this.task.ContinueWith(
                    t =>
     {
         pTaskBody.DoWork(this, 0, Array.Empty <IVsTask>(), out object result);
         return result;
     },
                    this.cancellationTokenSource.Token,
                    TaskContinuationOptions.None,
                    (TaskScheduler)this.vsTaskSchedulerService2.GetTaskScheduler(context)),
                pAsyncState));
 }
Exemplo n.º 6
0
        private FakeIVsTask(
            FakeIVsTask parent,
            __VSTASKRUNCONTEXT context,
            __VSTASKCONTINUATIONOPTIONS options,
            IVsTaskBody body,
            object asyncState)
        {
            TaskScheduler           scheduler           = GetSchedulerFromContext(context);
            TaskContinuationOptions continuationOptions = GetTaskContinuationOptions(options);

            _t = parent._t.ContinueWith(
                (task, state) =>
            {
                body.DoWork(this, 1, new IVsTask[] { parent }, out object result);
                return(result);
            },
                asyncState,
                default(CancellationToken),
                continuationOptions,
                scheduler);
            parent.OnMarkedAsBlocking?.Invoke(parent, new BlockingTaskEventArgs(parent, this));
        }
 public IVsTask ContinueWithEx(uint context, uint options, IVsTaskBody taskBody, object asyncState)
 {
     VsTask continuation = new VsTask(this.owner, (VsTaskRunContext)context, () =>
     {
         object taskBodyResult;
         taskBody.DoWork(null, 0, null, out taskBodyResult);
         return taskBodyResult;
     });
     continuation.Start();
     return continuation;
 }