Exemplo n.º 1
0
        /// <summary>
        /// Queue a work item
        /// </summary>
        /// <param name="callback">A callback to execute</param>
        /// <param name="state">
        /// The context object of the work item. Used for passing arguments to the work item.
        /// </param>
        /// <returns>Returns a work item result</returns>
        public IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state)
        {
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, WIGStartInfo, callback, state);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Queue a work item
        /// </summary>
        /// <param name="callback">A callback to execute</param>
        /// <param name="state">
        /// The context object of the work item. Used for passing arguments to the work item.
        /// </param>
        /// <param name="workItemPriority">The work item priority</param>
        /// <returns>Returns a work item result</returns>
        public IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, WorkItemPriority workItemPriority)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, WIGStartInfo, callback, state, workItemPriority);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Queue a work item
        /// </summary>
        /// <param name="workItemInfo">Work item info</param>
        /// <param name="callback">A callback to execute</param>
        /// <returns>Returns a work item result</returns>
        public IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, WIGStartInfo, workItemInfo, callback);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Queue a work item
        /// </summary>
        /// <param name="callback">A callback to execute</param>
        /// <param name="state">
        /// The context object of the work item. Used for passing arguments to the work item.
        /// </param>
        /// <param name="postExecuteWorkItemCallback">
        /// A delegate to call after the callback completion
        /// </param>
        /// <returns>Returns a work item result</returns>
        public IWorkItemResult QueueWorkItem(
            WorkItemCallback callback,
            object state,
            PostExecuteWorkItemCallback postExecuteWorkItemCallback)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, WIGStartInfo, callback, state, postExecuteWorkItemCallback);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
Exemplo n.º 5
0
        public IWorkItemResult <TResult> QueueWorkItem <TResult>(Func <TResult> func)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                state =>
            {
                return(func.Invoke());
            });

            Enqueue(workItem);
            return(new WorkItemResultTWrapper <TResult>(workItem.GetWorkItemResult()));
        }
Exemplo n.º 6
0
        public IWorkItemResult <TResult> QueueWorkItem <T1, T2, TResult>(Func <T1, T2, TResult> func, T1 arg1, T2 arg2)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                state =>
            {
                return(func.Invoke(arg1, arg2));
            },
                WIGStartInfo.FillStateWithArgs ? new object[] { arg1, arg2 } : null);

            Enqueue(workItem);
            return(new WorkItemResultTWrapper <TResult>(workItem.GetWorkItemResult()));
        }
Exemplo n.º 7
0
        public IWorkItemResult QueueWorkItem(Action action, WorkItemPriority priority)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                delegate
            {
                action.Invoke();
                return(null);
            }, priority);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
Exemplo n.º 8
0
        public IWorkItemResult QueueWorkItem <T1, T2, T3>(Action <T1, T2, T3> action, T1 arg1, T2 arg2, T3 arg3, WorkItemPriority priority)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                state =>
            {
                action.Invoke(arg1, arg2, arg3);
                return(null);
            },
                WIGStartInfo.FillStateWithArgs ? new object[] { arg1, arg2, arg3 } : null, priority);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }