aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/SmartThreadPool/WorkItemFactory.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ThirdParty/SmartThreadPool/WorkItemFactory.cs686
1 files changed, 343 insertions, 343 deletions
diff --git a/ThirdParty/SmartThreadPool/WorkItemFactory.cs b/ThirdParty/SmartThreadPool/WorkItemFactory.cs
index 2d6601e..16ccd81 100644
--- a/ThirdParty/SmartThreadPool/WorkItemFactory.cs
+++ b/ThirdParty/SmartThreadPool/WorkItemFactory.cs
@@ -1,343 +1,343 @@
1using System; 1using System;
2 2
3namespace Amib.Threading.Internal 3namespace Amib.Threading.Internal
4{ 4{
5 #region WorkItemFactory class 5 #region WorkItemFactory class
6 6
7 public class WorkItemFactory 7 public class WorkItemFactory
8 { 8 {
9 /// <summary> 9 /// <summary>
10 /// Create a new work item 10 /// Create a new work item
11 /// </summary> 11 /// </summary>
12 /// <param name="workItemsGroup">The WorkItemsGroup of this workitem</param> 12 /// <param name="workItemsGroup">The WorkItemsGroup of this workitem</param>
13 /// <param name="wigStartInfo">Work item group start information</param> 13 /// <param name="wigStartInfo">Work item group start information</param>
14 /// <param name="callback">A callback to execute</param> 14 /// <param name="callback">A callback to execute</param>
15 /// <returns>Returns a work item</returns> 15 /// <returns>Returns a work item</returns>
16 public static WorkItem CreateWorkItem( 16 public static WorkItem CreateWorkItem(
17 IWorkItemsGroup workItemsGroup, 17 IWorkItemsGroup workItemsGroup,
18 WIGStartInfo wigStartInfo, 18 WIGStartInfo wigStartInfo,
19 WorkItemCallback callback) 19 WorkItemCallback callback)
20 { 20 {
21 return CreateWorkItem(workItemsGroup, wigStartInfo, callback, null); 21 return CreateWorkItem(workItemsGroup, wigStartInfo, callback, null);
22 } 22 }
23 23
24 /// <summary> 24 /// <summary>
25 /// Create a new work item 25 /// Create a new work item
26 /// </summary> 26 /// </summary>
27 /// <param name="workItemsGroup">The WorkItemsGroup of this workitem</param> 27 /// <param name="workItemsGroup">The WorkItemsGroup of this workitem</param>
28 /// <param name="wigStartInfo">Work item group start information</param> 28 /// <param name="wigStartInfo">Work item group start information</param>
29 /// <param name="callback">A callback to execute</param> 29 /// <param name="callback">A callback to execute</param>
30 /// <param name="workItemPriority">The priority of the work item</param> 30 /// <param name="workItemPriority">The priority of the work item</param>
31 /// <returns>Returns a work item</returns> 31 /// <returns>Returns a work item</returns>
32 public static WorkItem CreateWorkItem( 32 public static WorkItem CreateWorkItem(
33 IWorkItemsGroup workItemsGroup, 33 IWorkItemsGroup workItemsGroup,
34 WIGStartInfo wigStartInfo, 34 WIGStartInfo wigStartInfo,
35 WorkItemCallback callback, 35 WorkItemCallback callback,
36 WorkItemPriority workItemPriority) 36 WorkItemPriority workItemPriority)
37 { 37 {
38 return CreateWorkItem(workItemsGroup, wigStartInfo, callback, null, workItemPriority); 38 return CreateWorkItem(workItemsGroup, wigStartInfo, callback, null, workItemPriority);
39 } 39 }
40 40
41 /// <summary> 41 /// <summary>
42 /// Create a new work item 42 /// Create a new work item
43 /// </summary> 43 /// </summary>
44 /// <param name="workItemsGroup">The WorkItemsGroup of this workitem</param> 44 /// <param name="workItemsGroup">The WorkItemsGroup of this workitem</param>
45 /// <param name="wigStartInfo">Work item group start information</param> 45 /// <param name="wigStartInfo">Work item group start information</param>
46 /// <param name="workItemInfo">Work item info</param> 46 /// <param name="workItemInfo">Work item info</param>
47 /// <param name="callback">A callback to execute</param> 47 /// <param name="callback">A callback to execute</param>
48 /// <returns>Returns a work item</returns> 48 /// <returns>Returns a work item</returns>
49 public static WorkItem CreateWorkItem( 49 public static WorkItem CreateWorkItem(
50 IWorkItemsGroup workItemsGroup, 50 IWorkItemsGroup workItemsGroup,
51 WIGStartInfo wigStartInfo, 51 WIGStartInfo wigStartInfo,
52 WorkItemInfo workItemInfo, 52 WorkItemInfo workItemInfo,
53 WorkItemCallback callback) 53 WorkItemCallback callback)
54 { 54 {
55 return CreateWorkItem( 55 return CreateWorkItem(
56 workItemsGroup, 56 workItemsGroup,
57 wigStartInfo, 57 wigStartInfo,
58 workItemInfo, 58 workItemInfo,
59 callback, 59 callback,
60 null); 60 null);
61 } 61 }
62 62
63 /// <summary> 63 /// <summary>
64 /// Create a new work item 64 /// Create a new work item
65 /// </summary> 65 /// </summary>
66 /// <param name="workItemsGroup">The WorkItemsGroup of this workitem</param> 66 /// <param name="workItemsGroup">The WorkItemsGroup of this workitem</param>
67 /// <param name="wigStartInfo">Work item group start information</param> 67 /// <param name="wigStartInfo">Work item group start information</param>
68 /// <param name="callback">A callback to execute</param> 68 /// <param name="callback">A callback to execute</param>
69 /// <param name="state"> 69 /// <param name="state">
70 /// The context object of the work item. Used for passing arguments to the work item. 70 /// The context object of the work item. Used for passing arguments to the work item.
71 /// </param> 71 /// </param>
72 /// <returns>Returns a work item</returns> 72 /// <returns>Returns a work item</returns>
73 public static WorkItem CreateWorkItem( 73 public static WorkItem CreateWorkItem(
74 IWorkItemsGroup workItemsGroup, 74 IWorkItemsGroup workItemsGroup,
75 WIGStartInfo wigStartInfo, 75 WIGStartInfo wigStartInfo,
76 WorkItemCallback callback, 76 WorkItemCallback callback,
77 object state) 77 object state)
78 { 78 {
79 ValidateCallback(callback); 79 ValidateCallback(callback);
80 80
81 WorkItemInfo workItemInfo = new WorkItemInfo(); 81 WorkItemInfo workItemInfo = new WorkItemInfo();
82 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 82 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
83 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 83 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
84 workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback; 84 workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback;
85 workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; 85 workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute;
86 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 86 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
87 workItemInfo.WorkItemPriority = wigStartInfo.WorkItemPriority; 87 workItemInfo.WorkItemPriority = wigStartInfo.WorkItemPriority;
88 88
89 WorkItem workItem = new WorkItem( 89 WorkItem workItem = new WorkItem(
90 workItemsGroup, 90 workItemsGroup,
91 workItemInfo, 91 workItemInfo,
92 callback, 92 callback,
93 state); 93 state);
94 return workItem; 94 return workItem;
95 } 95 }
96 96
97 /// <summary> 97 /// <summary>
98 /// Create a new work item 98 /// Create a new work item
99 /// </summary> 99 /// </summary>
100 /// <param name="workItemsGroup">The work items group</param> 100 /// <param name="workItemsGroup">The work items group</param>
101 /// <param name="wigStartInfo">Work item group start information</param> 101 /// <param name="wigStartInfo">Work item group start information</param>
102 /// <param name="callback">A callback to execute</param> 102 /// <param name="callback">A callback to execute</param>
103 /// <param name="state"> 103 /// <param name="state">
104 /// The context object of the work item. Used for passing arguments to the work item. 104 /// The context object of the work item. Used for passing arguments to the work item.
105 /// </param> 105 /// </param>
106 /// <param name="workItemPriority">The work item priority</param> 106 /// <param name="workItemPriority">The work item priority</param>
107 /// <returns>Returns a work item</returns> 107 /// <returns>Returns a work item</returns>
108 public static WorkItem CreateWorkItem( 108 public static WorkItem CreateWorkItem(
109 IWorkItemsGroup workItemsGroup, 109 IWorkItemsGroup workItemsGroup,
110 WIGStartInfo wigStartInfo, 110 WIGStartInfo wigStartInfo,
111 WorkItemCallback callback, 111 WorkItemCallback callback,
112 object state, 112 object state,
113 WorkItemPriority workItemPriority) 113 WorkItemPriority workItemPriority)
114 { 114 {
115 ValidateCallback(callback); 115 ValidateCallback(callback);
116 116
117 WorkItemInfo workItemInfo = new WorkItemInfo(); 117 WorkItemInfo workItemInfo = new WorkItemInfo();
118 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 118 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
119 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 119 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
120 workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback; 120 workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback;
121 workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; 121 workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute;
122 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 122 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
123 workItemInfo.WorkItemPriority = workItemPriority; 123 workItemInfo.WorkItemPriority = workItemPriority;
124 124
125 WorkItem workItem = new WorkItem( 125 WorkItem workItem = new WorkItem(
126 workItemsGroup, 126 workItemsGroup,
127 workItemInfo, 127 workItemInfo,
128 callback, 128 callback,
129 state); 129 state);
130 130
131 return workItem; 131 return workItem;
132 } 132 }
133 133
134 /// <summary> 134 /// <summary>
135 /// Create a new work item 135 /// Create a new work item
136 /// </summary> 136 /// </summary>
137 /// <param name="workItemsGroup">The work items group</param> 137 /// <param name="workItemsGroup">The work items group</param>
138 /// <param name="wigStartInfo">Work item group start information</param> 138 /// <param name="wigStartInfo">Work item group start information</param>
139 /// <param name="workItemInfo">Work item information</param> 139 /// <param name="workItemInfo">Work item information</param>
140 /// <param name="callback">A callback to execute</param> 140 /// <param name="callback">A callback to execute</param>
141 /// <param name="state"> 141 /// <param name="state">
142 /// The context object of the work item. Used for passing arguments to the work item. 142 /// The context object of the work item. Used for passing arguments to the work item.
143 /// </param> 143 /// </param>
144 /// <returns>Returns a work item</returns> 144 /// <returns>Returns a work item</returns>
145 public static WorkItem CreateWorkItem( 145 public static WorkItem CreateWorkItem(
146 IWorkItemsGroup workItemsGroup, 146 IWorkItemsGroup workItemsGroup,
147 WIGStartInfo wigStartInfo, 147 WIGStartInfo wigStartInfo,
148 WorkItemInfo workItemInfo, 148 WorkItemInfo workItemInfo,
149 WorkItemCallback callback, 149 WorkItemCallback callback,
150 object state) 150 object state)
151 { 151 {
152 ValidateCallback(callback); 152 ValidateCallback(callback);
153 ValidateCallback(workItemInfo.PostExecuteWorkItemCallback); 153 ValidateCallback(workItemInfo.PostExecuteWorkItemCallback);
154 154
155 WorkItem workItem = new WorkItem( 155 WorkItem workItem = new WorkItem(
156 workItemsGroup, 156 workItemsGroup,
157 new WorkItemInfo(workItemInfo), 157 new WorkItemInfo(workItemInfo),
158 callback, 158 callback,
159 state); 159 state);
160 160
161 return workItem; 161 return workItem;
162 } 162 }
163 163
164 /// <summary> 164 /// <summary>
165 /// Create a new work item 165 /// Create a new work item
166 /// </summary> 166 /// </summary>
167 /// <param name="workItemsGroup">The work items group</param> 167 /// <param name="workItemsGroup">The work items group</param>
168 /// <param name="wigStartInfo">Work item group start information</param> 168 /// <param name="wigStartInfo">Work item group start information</param>
169 /// <param name="callback">A callback to execute</param> 169 /// <param name="callback">A callback to execute</param>
170 /// <param name="state"> 170 /// <param name="state">
171 /// The context object of the work item. Used for passing arguments to the work item. 171 /// The context object of the work item. Used for passing arguments to the work item.
172 /// </param> 172 /// </param>
173 /// <param name="postExecuteWorkItemCallback"> 173 /// <param name="postExecuteWorkItemCallback">
174 /// A delegate to call after the callback completion 174 /// A delegate to call after the callback completion
175 /// </param> 175 /// </param>
176 /// <returns>Returns a work item</returns> 176 /// <returns>Returns a work item</returns>
177 public static WorkItem CreateWorkItem( 177 public static WorkItem CreateWorkItem(
178 IWorkItemsGroup workItemsGroup, 178 IWorkItemsGroup workItemsGroup,
179 WIGStartInfo wigStartInfo, 179 WIGStartInfo wigStartInfo,
180 WorkItemCallback callback, 180 WorkItemCallback callback,
181 object state, 181 object state,
182 PostExecuteWorkItemCallback postExecuteWorkItemCallback) 182 PostExecuteWorkItemCallback postExecuteWorkItemCallback)
183 { 183 {
184 ValidateCallback(callback); 184 ValidateCallback(callback);
185 ValidateCallback(postExecuteWorkItemCallback); 185 ValidateCallback(postExecuteWorkItemCallback);
186 186
187 WorkItemInfo workItemInfo = new WorkItemInfo(); 187 WorkItemInfo workItemInfo = new WorkItemInfo();
188 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 188 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
189 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 189 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
190 workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; 190 workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
191 workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; 191 workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute;
192 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 192 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
193 workItemInfo.WorkItemPriority = wigStartInfo.WorkItemPriority; 193 workItemInfo.WorkItemPriority = wigStartInfo.WorkItemPriority;
194 194
195 WorkItem workItem = new WorkItem( 195 WorkItem workItem = new WorkItem(
196 workItemsGroup, 196 workItemsGroup,
197 workItemInfo, 197 workItemInfo,
198 callback, 198 callback,
199 state); 199 state);
200 200
201 return workItem; 201 return workItem;
202 } 202 }
203 203
204 /// <summary> 204 /// <summary>
205 /// Create a new work item 205 /// Create a new work item
206 /// </summary> 206 /// </summary>
207 /// <param name="workItemsGroup">The work items group</param> 207 /// <param name="workItemsGroup">The work items group</param>
208 /// <param name="wigStartInfo">Work item group start information</param> 208 /// <param name="wigStartInfo">Work item group start information</param>
209 /// <param name="callback">A callback to execute</param> 209 /// <param name="callback">A callback to execute</param>
210 /// <param name="state"> 210 /// <param name="state">
211 /// The context object of the work item. Used for passing arguments to the work item. 211 /// The context object of the work item. Used for passing arguments to the work item.
212 /// </param> 212 /// </param>
213 /// <param name="postExecuteWorkItemCallback"> 213 /// <param name="postExecuteWorkItemCallback">
214 /// A delegate to call after the callback completion 214 /// A delegate to call after the callback completion
215 /// </param> 215 /// </param>
216 /// <param name="workItemPriority">The work item priority</param> 216 /// <param name="workItemPriority">The work item priority</param>
217 /// <returns>Returns a work item</returns> 217 /// <returns>Returns a work item</returns>
218 public static WorkItem CreateWorkItem( 218 public static WorkItem CreateWorkItem(
219 IWorkItemsGroup workItemsGroup, 219 IWorkItemsGroup workItemsGroup,
220 WIGStartInfo wigStartInfo, 220 WIGStartInfo wigStartInfo,
221 WorkItemCallback callback, 221 WorkItemCallback callback,
222 object state, 222 object state,
223 PostExecuteWorkItemCallback postExecuteWorkItemCallback, 223 PostExecuteWorkItemCallback postExecuteWorkItemCallback,
224 WorkItemPriority workItemPriority) 224 WorkItemPriority workItemPriority)
225 { 225 {
226 ValidateCallback(callback); 226 ValidateCallback(callback);
227 ValidateCallback(postExecuteWorkItemCallback); 227 ValidateCallback(postExecuteWorkItemCallback);
228 228
229 WorkItemInfo workItemInfo = new WorkItemInfo(); 229 WorkItemInfo workItemInfo = new WorkItemInfo();
230 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 230 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
231 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 231 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
232 workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; 232 workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
233 workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; 233 workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute;
234 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 234 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
235 workItemInfo.WorkItemPriority = workItemPriority; 235 workItemInfo.WorkItemPriority = workItemPriority;
236 236
237 WorkItem workItem = new WorkItem( 237 WorkItem workItem = new WorkItem(
238 workItemsGroup, 238 workItemsGroup,
239 workItemInfo, 239 workItemInfo,
240 callback, 240 callback,
241 state); 241 state);
242 242
243 return workItem; 243 return workItem;
244 } 244 }
245 245
246 /// <summary> 246 /// <summary>
247 /// Create a new work item 247 /// Create a new work item
248 /// </summary> 248 /// </summary>
249 /// <param name="workItemsGroup">The work items group</param> 249 /// <param name="workItemsGroup">The work items group</param>
250 /// <param name="wigStartInfo">Work item group start information</param> 250 /// <param name="wigStartInfo">Work item group start information</param>
251 /// <param name="callback">A callback to execute</param> 251 /// <param name="callback">A callback to execute</param>
252 /// <param name="state"> 252 /// <param name="state">
253 /// The context object of the work item. Used for passing arguments to the work item. 253 /// The context object of the work item. Used for passing arguments to the work item.
254 /// </param> 254 /// </param>
255 /// <param name="postExecuteWorkItemCallback"> 255 /// <param name="postExecuteWorkItemCallback">
256 /// A delegate to call after the callback completion 256 /// A delegate to call after the callback completion
257 /// </param> 257 /// </param>
258 /// <param name="callToPostExecute">Indicates on which cases to call to the post execute callback</param> 258 /// <param name="callToPostExecute">Indicates on which cases to call to the post execute callback</param>
259 /// <returns>Returns a work item</returns> 259 /// <returns>Returns a work item</returns>
260 public static WorkItem CreateWorkItem( 260 public static WorkItem CreateWorkItem(
261 IWorkItemsGroup workItemsGroup, 261 IWorkItemsGroup workItemsGroup,
262 WIGStartInfo wigStartInfo, 262 WIGStartInfo wigStartInfo,
263 WorkItemCallback callback, 263 WorkItemCallback callback,
264 object state, 264 object state,
265 PostExecuteWorkItemCallback postExecuteWorkItemCallback, 265 PostExecuteWorkItemCallback postExecuteWorkItemCallback,
266 CallToPostExecute callToPostExecute) 266 CallToPostExecute callToPostExecute)
267 { 267 {
268 ValidateCallback(callback); 268 ValidateCallback(callback);
269 ValidateCallback(postExecuteWorkItemCallback); 269 ValidateCallback(postExecuteWorkItemCallback);
270 270
271 WorkItemInfo workItemInfo = new WorkItemInfo(); 271 WorkItemInfo workItemInfo = new WorkItemInfo();
272 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 272 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
273 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 273 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
274 workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; 274 workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
275 workItemInfo.CallToPostExecute = callToPostExecute; 275 workItemInfo.CallToPostExecute = callToPostExecute;
276 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 276 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
277 workItemInfo.WorkItemPriority = wigStartInfo.WorkItemPriority; 277 workItemInfo.WorkItemPriority = wigStartInfo.WorkItemPriority;
278 278
279 WorkItem workItem = new WorkItem( 279 WorkItem workItem = new WorkItem(
280 workItemsGroup, 280 workItemsGroup,
281 workItemInfo, 281 workItemInfo,
282 callback, 282 callback,
283 state); 283 state);
284 284
285 return workItem; 285 return workItem;
286 } 286 }
287 287
288 /// <summary> 288 /// <summary>
289 /// Create a new work item 289 /// Create a new work item
290 /// </summary> 290 /// </summary>
291 /// <param name="workItemsGroup">The work items group</param> 291 /// <param name="workItemsGroup">The work items group</param>
292 /// <param name="wigStartInfo">Work item group start information</param> 292 /// <param name="wigStartInfo">Work item group start information</param>
293 /// <param name="callback">A callback to execute</param> 293 /// <param name="callback">A callback to execute</param>
294 /// <param name="state"> 294 /// <param name="state">
295 /// The context object of the work item. Used for passing arguments to the work item. 295 /// The context object of the work item. Used for passing arguments to the work item.
296 /// </param> 296 /// </param>
297 /// <param name="postExecuteWorkItemCallback"> 297 /// <param name="postExecuteWorkItemCallback">
298 /// A delegate to call after the callback completion 298 /// A delegate to call after the callback completion
299 /// </param> 299 /// </param>
300 /// <param name="callToPostExecute">Indicates on which cases to call to the post execute callback</param> 300 /// <param name="callToPostExecute">Indicates on which cases to call to the post execute callback</param>
301 /// <param name="workItemPriority">The work item priority</param> 301 /// <param name="workItemPriority">The work item priority</param>
302 /// <returns>Returns a work item</returns> 302 /// <returns>Returns a work item</returns>
303 public static WorkItem CreateWorkItem( 303 public static WorkItem CreateWorkItem(
304 IWorkItemsGroup workItemsGroup, 304 IWorkItemsGroup workItemsGroup,
305 WIGStartInfo wigStartInfo, 305 WIGStartInfo wigStartInfo,
306 WorkItemCallback callback, 306 WorkItemCallback callback,
307 object state, 307 object state,
308 PostExecuteWorkItemCallback postExecuteWorkItemCallback, 308 PostExecuteWorkItemCallback postExecuteWorkItemCallback,
309 CallToPostExecute callToPostExecute, 309 CallToPostExecute callToPostExecute,
310 WorkItemPriority workItemPriority) 310 WorkItemPriority workItemPriority)
311 { 311 {
312 312
313 ValidateCallback(callback); 313 ValidateCallback(callback);
314 ValidateCallback(postExecuteWorkItemCallback); 314 ValidateCallback(postExecuteWorkItemCallback);
315 315
316 WorkItemInfo workItemInfo = new WorkItemInfo(); 316 WorkItemInfo workItemInfo = new WorkItemInfo();
317 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 317 workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
318 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 318 workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
319 workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; 319 workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
320 workItemInfo.CallToPostExecute = callToPostExecute; 320 workItemInfo.CallToPostExecute = callToPostExecute;
321 workItemInfo.WorkItemPriority = workItemPriority; 321 workItemInfo.WorkItemPriority = workItemPriority;
322 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 322 workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
323 323
324 WorkItem workItem = new WorkItem( 324 WorkItem workItem = new WorkItem(
325 workItemsGroup, 325 workItemsGroup,
326 workItemInfo, 326 workItemInfo,
327 callback, 327 callback,
328 state); 328 state);
329 329
330 return workItem; 330 return workItem;
331 } 331 }
332 332
333 private static void ValidateCallback(Delegate callback) 333 private static void ValidateCallback(Delegate callback)
334 { 334 {
335 if (callback != null && callback.GetInvocationList().Length > 1) 335 if (callback != null && callback.GetInvocationList().Length > 1)
336 { 336 {
337 throw new NotSupportedException("SmartThreadPool doesn't support delegates chains"); 337 throw new NotSupportedException("SmartThreadPool doesn't support delegates chains");
338 } 338 }
339 } 339 }
340 } 340 }
341 341
342 #endregion 342 #endregion
343} 343}