CreateWorkItem() public static method

Create a new work item
public static CreateWorkItem ( IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemCallback callback ) : WorkItem
workItemsGroup IWorkItemsGroup
wigStartInfo WIGStartInfo Work item group start information
callback WorkItemCallback A callback to execute
return WorkItem
Ejemplo n.º 1
0
        /// <summary>
        /// Queue a work item
        /// </summary>
        /// <param name="callback">A callback to execute</param>
        /// <param name="workItemPriority">The priority of the work item</param>
        /// <returns>Returns a work item result</returns>
        public IWorkItemResult QueueWorkItem(WorkItemCallback callback, WorkItemPriority workItemPriority)
        {
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, WIGStartInfo, callback, workItemPriority);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
Ejemplo 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)
        {
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, _workItemsGroupStartInfo, callback, state, workItemPriority);

            EnqueueToSTPNextWorkItem(workItem);
            return(workItem.GetWorkItemResult());
        }
        /// <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());
        }
Ejemplo n.º 4
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)
        {
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, _workItemsGroupStartInfo, workItemInfo, callback);

            EnqueueToSTPNextWorkItem(workItem);
            return(workItem.GetWorkItemResult());
        }
Ejemplo n.º 5
0
        public IWorkItemResult QueueWorkItem(WaitCallback callback)
        {
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, WIGStartInfo, callback, null);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
        /// <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());
        }
Ejemplo n.º 7
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>
        /// <param name="callToPostExecute">Indicates on which cases to call to the post execute callback</param>
        /// <returns>Returns a work item result</returns>
        public IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state,
                                             PostExecuteWorkItemCallback postExecuteWorkItemCallback, CallToPostExecute callToPostExecute)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, WIGStartInfo, callback, state, postExecuteWorkItemCallback, callToPostExecute);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
Ejemplo n.º 8
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)
        {
            WorkItem workItem = WorkItemFactory.CreateWorkItem(this, _workItemsGroupStartInfo, callback, state, postExecuteWorkItemCallback);

            EnqueueToSTPNextWorkItem(workItem);
            return(workItem.GetWorkItemResult());
        }
        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()));
        }
Ejemplo n.º 10
0
        public IWorkItemResult <TResult> QueueWorkItem <TResult>(Func <TResult> func, WorkItemPriority priority = SmartThreadPool.DefaultWorkItemPriority)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                state =>
            {
                return(func.Invoke());
            }, priority);

            Enqueue(workItem);
            return(new WorkItemResultTWrapper <TResult>(workItem.GetWorkItemResult()));
        }
        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()));
        }
        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());
        }
Ejemplo n.º 13
0
        public IWorkItemResult <TResult> QueueWorkItem <T1, T2, TResult>(Func <T1, T2, TResult> func, T1 arg1, T2 arg2, WorkItemPriority priority = SmartThreadPool.DefaultWorkItemPriority)
        {
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                state =>
            {
                return(func.Invoke(arg1, arg2));
            },
                WIGStartInfo.FillStateWithArgs ? new object[] { arg1, arg2 } : null,
                priority);

            Enqueue(workItem);
            return(new WorkItemResultTWrapper <TResult>(workItem.GetWorkItemResult()));
        }
Ejemplo n.º 14
0
        public IWorkItemResult QueueWorkItem <T1, T2>(Action <T1, T2> action, T1 arg1, T2 arg2, WorkItemPriority priority = SmartThreadPool.DefaultWorkItemPriority)
        {
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                state =>
            {
                action.Invoke(arg1, arg2);
                return(null);
            },
                WIGStartInfo.FillStateWithArgs ? new object[] { arg1, arg2 } : null, priority);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
        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());
        }
Ejemplo n.º 16
0
        public IWorkItemResult QueueWorkItem <T> (Action <T> action, T arg)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                state =>
            {
                action.Invoke(arg);
                return(null);
            },
                WIGStartInfo.FillStateWithArgs ? new object[] { arg } : null);

            Enqueue(workItem);
            return(workItem.GetWorkItemResult());
        }
Ejemplo n.º 17
0
        public IWorkItemResult <TResult> QueueWorkItem <T, TResult>(Func <T, TResult> func, T arg, WorkItemPriority priority = WorkItemPriority.Normal)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                state =>
            {
                return(func.Invoke(arg));
            },
                WIGStartInfo.FillStateWithArgs ? new object[] { arg } : null,
                priority);

            Enqueue(workItem);
            return(new WorkItemResultTWrapper <TResult>(workItem.GetWorkItemResult()));
        }
        public IWorkItemResult QueueWorkItem <T1, T2>(Action <T1, T2> action, T1 arg1, T2 arg2)
        {
            PreQueueWorkItem();
            WorkItem workItem = WorkItemFactory.CreateWorkItem(
                this,
                WIGStartInfo,
                delegate
            {
                action.Invoke(arg1, arg2);
                return(null);
            },
                WIGStartInfo.FillStateWithArgs ? new object[] { arg1, arg2 } : null);

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