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