本文整理汇总了C#中WorkItemCallback类的典型用法代码示例。如果您正苦于以下问题:C# WorkItemCallback类的具体用法?C# WorkItemCallback怎么用?C# WorkItemCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkItemCallback类属于命名空间,在下文中一共展示了WorkItemCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateWorkItem
/// <summary>
/// Create a new work item
/// </summary>
/// <param name = "wigStartInfo">Work item group start information</param>
/// <param name = "callback">A callback to execute</param>
/// <returns>Returns a work item</returns>
public static WorkItem CreateWorkItem(
IWorkItemsGroup workItemsGroup,
WIGStartInfo wigStartInfo,
WorkItemCallback callback)
{
return CreateWorkItem(workItemsGroup, wigStartInfo, callback, null);
}
示例2: Post
public static void Post(WorkItemCallback callback)
{
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
throw new PlatformNotSupportedException(System.Web.SR.GetString("RequiresNT"));
}
PostInternal(callback);
}
示例3: Post
public static void Post(WorkItemCallback callback) {
#if !FEATURE_PAL // ROTORTODO
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
throw new PlatformNotSupportedException(SR.GetString(SR.RequiresNT));
#else // !FEATURE_PAL
throw new NotImplementedException("ROTORTODO");
#endif // !FEATURE_PAL
PostInternal(callback);
}
示例4: PostInternal
internal static void PostInternal(WorkItemCallback callback) {
if (_useQueueUserWorkItem) {
ThreadPool.QueueUserWorkItem(_onQueueUserWorkItemCompletion, callback);
}
else {
WrappedWorkItemCallback w = new WrappedWorkItemCallback(callback);
w.Post();
}
}
示例5: ChainedDelegatesCallback
public void ChainedDelegatesCallback()
{
SmartThreadPool stp = new SmartThreadPool();
WorkItemCallback workItemCallback = new WorkItemCallback(DoWork);
workItemCallback += new WorkItemCallback(DoWork);
stp.QueueWorkItem(workItemCallback);
stp.WaitForIdle();
stp.Shutdown();
}
示例6: CreateWorkItem
// Token: 0x0600185F RID: 6239
// RVA: 0x00075274 File Offset: 0x00073474
public static WorkItem CreateWorkItem(IWorkItemsGroup iworkItemsGroup_0, WIGStartInfo wigstartInfo_0, WorkItemCallback workItemCallback_0, object object_0, WorkItemPriority workItemPriority_0)
{
WorkItemFactory.ValidateCallback(workItemCallback_0);
return new WorkItem(iworkItemsGroup_0, new WorkItemInfo
{
UseCallerCallContext = wigstartInfo_0.UseCallerCallContext,
UseCallerHttpContext = wigstartInfo_0.UseCallerHttpContext,
PostExecuteWorkItemCallback = wigstartInfo_0.PostExecuteWorkItemCallback,
CallToPostExecute = wigstartInfo_0.CallToPostExecute,
DisposeOfStateObjects = wigstartInfo_0.DisposeOfStateObjects,
WorkItemPriority = workItemPriority_0
}, workItemCallback_0, object_0);
}
示例7: ChainedDelegatesCallback
public void ChainedDelegatesCallback()
{
SmartThreadPool smartThreadPool = new SmartThreadPool();
IWorkItemsGroup workItemsGroup = smartThreadPool.CreateWorkItemsGroup(int.MaxValue);
WorkItemCallback workItemCallback = new WorkItemCallback(DoWork);
workItemCallback += new WorkItemCallback(DoWork);
workItemsGroup.QueueWorkItem(workItemCallback);
workItemsGroup.WaitForIdle();
smartThreadPool.Shutdown();
}
示例8: WorkItem
internal WorkItem(Delegate func, object[] state)
{
_state = state;
_stuck = func.Method.ReturnType != typeof(void);
_callback = new WorkItemCallback(
delegate {
if (_stuck) {
return func.Method.Invoke(func.Target, state);
}
else {
func.Method.Invoke(func.Target, state);
return null;
}
});
}
示例9: ChainedDelegatesCallback
public void ChainedDelegatesCallback()
{
Assert.Throws<NotSupportedException>(() =>
{
SmartThreadPool stp = new SmartThreadPool();
WorkItemCallback workItemCallback = new WorkItemCallback(DoWork);
workItemCallback += new WorkItemCallback(DoWork);
stp.QueueWorkItem(workItemCallback);
stp.WaitForIdle();
stp.Shutdown();
});
}
示例10: ChainedDelegatesCallback
public void ChainedDelegatesCallback()
{
Assert.Throws<NotSupportedException>(() =>
{
SmartThreadPool smartThreadPool = new SmartThreadPool();
IWorkItemsGroup workItemsGroup = smartThreadPool.CreateWorkItemsGroup(int.MaxValue);
WorkItemCallback workItemCallback = new WorkItemCallback(DoWork);
workItemCallback += new WorkItemCallback(DoWork);
workItemsGroup.QueueWorkItem(workItemCallback);
workItemsGroup.WaitForIdle();
smartThreadPool.Shutdown();
});
}
示例11: CreateWorkItem
/// <summary>
/// Create a new work item
/// </summary>
/// <param name="workItemsGroup"></param>
/// <param name="wigStartInfo">Work item group start information</param>
/// <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</returns>
public static WorkItem CreateWorkItem(
IWorkItemsGroup workItemsGroup,
WIGStartInfo wigStartInfo,
WorkItemCallback callback,
object state)
{
ValidateCallback(callback);
WorkItemInfo workItemInfo = new WorkItemInfo();
workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext;
workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext;
workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback;
workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute;
workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
WorkItem workItem = new WorkItem(
workItemsGroup,
workItemInfo,
callback,
state);
return workItem;
}
示例12: WorkItem
/// <summary>
/// Initialize the callback holding object.
/// </summary>
/// <param name="workItemsGroup"></param>
/// <param name="workItemInfo"></param>
/// <param name="callback">Callback delegate for the callback.</param>
/// <param name="state">State with which to call the callback delegate.</param>
///
/// We assume that the WorkItem object is created within the thread
/// that meant to run the callback
public WorkItem(
IWorkItemsGroup workItemsGroup,
WorkItemInfo workItemInfo,
WorkItemCallback callback,
object state)
{
_workItemsGroup = workItemsGroup;
_workItemInfo = workItemInfo;
if (_workItemInfo.UseCallerCallContext || _workItemInfo.UseCallerHttpContext)
{
_callerContext = CallerThreadContext.Capture(_workItemInfo.UseCallerCallContext, _workItemInfo.UseCallerHttpContext);
}
_callback = callback;
_state = state;
_workItemResult = new WorkItemResult(this);
Initialize();
}
示例13: WorkItem
/// <summary>
/// Initialize the callback holding object.
/// </summary>
/// <param name="workItemsGroup">The workItemGroup of the workitem</param>
/// <param name="workItemInfo">The WorkItemInfo of te workitem</param>
/// <param name="callback">Callback delegate for the callback.</param>
/// <param name="state">State with which to call the callback delegate.</param>
///
/// We assume that the WorkItem object is created within the thread
/// that meant to run the callback
public WorkItem(
IWorkItemsGroup workItemsGroup,
WorkItemInfo workItemInfo,
WorkItemCallback callback,
object state)
{
_workItemsGroup = workItemsGroup;
_workItemInfo = workItemInfo;
#if !(_WINDOWS_CE) && !(_SILVERLIGHT) && !(WINDOWS_PHONE)
if (_workItemInfo.UseCallerCallContext || _workItemInfo.UseCallerHttpContext)
{
_callerContext = CallerThreadContext.Capture(_workItemInfo.UseCallerCallContext, _workItemInfo.UseCallerHttpContext);
}
#endif
_callback = callback;
_state = state;
_workItemResult = new WorkItemResult(this);
Initialize();
}
示例14: CoreProcessRequest
protected void CoreProcessRequest() {
try {
bool transacted = protocol.MethodAttribute.TransactionEnabled;
if (protocol.IsOneWay) {
WorkItemCallback callback = null;
TraceMethod callbackMethod = null;
if (protocol.OnewayInitException != null) {
callback = new WorkItemCallback(this.ThrowInitException);
callbackMethod = Tracing.On ? new TraceMethod(this, "ThrowInitException") : null;
}
else {
parameters = protocol.ReadParameters();
callback = transacted ? new WorkItemCallback(this.OneWayInvokeTransacted) : new WorkItemCallback(this.OneWayInvoke);
callbackMethod = Tracing.On ? transacted ? new TraceMethod(this, "OneWayInvokeTransacted") : new TraceMethod(this, "OneWayInvoke") : null;
}
if (Tracing.On) Tracing.Information(Res.TracePostWorkItemIn, callbackMethod);
WorkItem.Post(callback);
if (Tracing.On) Tracing.Information(Res.TracePostWorkItemOut, callbackMethod);
protocol.WriteOneWayResponse();
}
else if (transacted) {
parameters = protocol.ReadParameters();
InvokeTransacted();
}
else {
parameters = protocol.ReadParameters();
Invoke();
}
}
catch (Exception e) {
if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) {
throw;
}
if (Tracing.On) Tracing.ExceptionCatch(TraceEventType.Error, this, "CoreProcessRequest", e);
if (!protocol.IsOneWay)
WriteException(e);
}
TraceFlush();
}
示例15: PostThreadPoolWorkItem
internal static extern int PostThreadPoolWorkItem(WorkItemCallback callback);