本文整理汇总了C#中System.ServiceModel.OperationContext.Recycle方法的典型用法代码示例。如果您正苦于以下问题:C# OperationContext.Recycle方法的具体用法?C# OperationContext.Recycle怎么用?C# OperationContext.Recycle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.OperationContext
的用法示例。
在下文中一共展示了OperationContext.Recycle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransactedBatchLoop
bool TransactedBatchLoop()
{
if (null != this.transactedBatchContext)
{
if (this.transactedBatchContext.InDispatch)
{
this.transactedBatchContext.ForceRollback();
this.transactedBatchContext.InDispatch = false;
}
if (!this.transactedBatchContext.IsActive)
{
if (!this.isMainTransactedBatchHandler)
{
return false;
}
this.transactedBatchContext = null;
}
}
if (null == this.transactedBatchContext)
{
try
{
this.receiver.WaitForMessage();
}
catch (Exception ex)
{
if (Fx.IsFatal(ex))
{
throw;
}
if (!this.HandleError(ex))
{
throw;
}
}
this.transactedBatchContext = this.sharedTransactedBatchContext.CreateTransactedBatchContext();
}
OperationContext existingOperationContext = OperationContext.Current;
try
{
OperationContext currentOperationContext = new OperationContext(this.host);
OperationContext.Current = currentOperationContext;
RequestContext request;
while (this.transactedBatchContext.IsActive)
{
this.requestInfo.Cleanup();
bool valid = TryTransactionalReceive(this.transactedBatchContext.Transaction, out request);
if (!valid)
{
if (this.IsOpen)
{
this.transactedBatchContext.ForceCommit();
return true;
}
else
{
this.transactedBatchContext.ForceRollback();
return false;
}
}
if (null == request)
{
this.transactedBatchContext.ForceRollback();
return false;
}
TransactionMessageProperty.Set(this.transactedBatchContext.Transaction, request.RequestMessage);
this.transactedBatchContext.InDispatch = true;
if (!HandleRequest(request, currentOperationContext))
{
return false;
}
if (this.transactedBatchContext.InDispatch)
{
this.transactedBatchContext.ForceRollback();
this.transactedBatchContext.InDispatch = false;
return true;
}
if (!TryAcquirePump())
{
Fx.Assert("System.ServiceModel.Dispatcher.ChannelHandler.TransactedBatchLoop(): (TryAcquiredPump returned false)");
return false;
}
currentOperationContext.Recycle();
}
}
finally
//.........这里部分代码省略.........
示例2: TransactedLoop
bool TransactedLoop()
{
try
{
this.receiver.WaitForMessage();
}
catch (Exception ex)
{
if (Fx.IsFatal(ex))
{
throw;
}
if (!this.HandleError(ex))
{
throw;
}
}
RequestContext request;
Transaction tx = CreateOrGetAttachedTransaction();
OperationContext existingOperationContext = OperationContext.Current;
try
{
OperationContext currentOperationContext = new OperationContext(this.host);
OperationContext.Current = currentOperationContext;
for (;;)
{
this.requestInfo.Cleanup();
bool received = TryTransactionalReceive(tx, out request);
if (!received)
{
return IsOpen;
}
if (null == request)
{
return false;
}
TransactionMessageProperty.Set(tx, request.RequestMessage);
if (!HandleRequest(request, currentOperationContext))
{
return false;
}
if (!TryAcquirePump())
{
return false;
}
tx = CreateOrGetAttachedTransaction();
currentOperationContext.Recycle();
}
}
finally
{
OperationContext.Current = existingOperationContext;
}
}
示例3: SyncMessagePump
void SyncMessagePump()
{
OperationContext existingOperationContext = OperationContext.Current;
try
{
OperationContext currentOperationContext = new OperationContext(this.host);
OperationContext.Current = currentOperationContext;
for (;;)
{
RequestContext request;
this.requestInfo.Cleanup();
while (!TryReceive(TimeSpan.MaxValue, out request))
{
}
if (!HandleRequest(request, currentOperationContext))
{
break;
}
if (!TryAcquirePump())
{
break;
}
currentOperationContext.Recycle();
}
}
finally
{
OperationContext.Current = existingOperationContext;
}
}
示例4: SyncMessagePump
private void SyncMessagePump()
{
OperationContext current = OperationContext.Current;
try
{
RequestContext context3;
OperationContext currentOperationContext = new OperationContext(this.host);
OperationContext.Current = currentOperationContext;
Label_0018:
this.requestInfo.Cleanup();
while (!this.TryReceive(TimeSpan.MaxValue, out context3))
{
}
if (this.HandleRequest(context3, currentOperationContext) && this.TryAcquirePump())
{
currentOperationContext.Recycle();
goto Label_0018;
}
}
finally
{
OperationContext.Current = current;
}
}
示例5: TransactedLoop
private bool TransactedLoop()
{
bool flag2;
try
{
this.receiver.WaitForMessage();
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
if (!this.HandleError(exception))
{
throw;
}
}
Transaction tx = this.CreateOrGetAttachedTransaction();
OperationContext current = OperationContext.Current;
try
{
RequestContext context;
OperationContext currentOperationContext = new OperationContext(this.host);
OperationContext.Current = currentOperationContext;
Label_0046:
this.requestInfo.Cleanup();
if (!this.TryTransactionalReceive(tx, out context))
{
return this.IsOpen;
}
if (context == null)
{
return false;
}
TransactionMessageProperty.Set(tx, context.RequestMessage);
if (!this.HandleRequest(context, currentOperationContext))
{
return false;
}
if (!this.TryAcquirePump())
{
flag2 = false;
}
else
{
tx = this.CreateOrGetAttachedTransaction();
currentOperationContext.Recycle();
goto Label_0046;
}
}
finally
{
OperationContext.Current = current;
}
return flag2;
}
示例6: TransactedBatchLoop
private bool TransactedBatchLoop()
{
if (this.transactedBatchContext != null)
{
if (this.transactedBatchContext.InDispatch)
{
this.transactedBatchContext.ForceRollback();
this.transactedBatchContext.InDispatch = false;
}
if (!this.transactedBatchContext.IsActive)
{
if (!this.isMainTransactedBatchHandler)
{
return false;
}
this.transactedBatchContext = null;
}
}
if (this.transactedBatchContext == null)
{
try
{
this.receiver.WaitForMessage();
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
if (!this.HandleError(exception))
{
throw;
}
}
this.transactedBatchContext = this.sharedTransactedBatchContext.CreateTransactedBatchContext();
}
OperationContext current = OperationContext.Current;
try
{
OperationContext currentOperationContext = new OperationContext(this.host);
OperationContext.Current = currentOperationContext;
while (this.transactedBatchContext.IsActive)
{
RequestContext context3;
this.requestInfo.Cleanup();
if (!this.TryTransactionalReceive(this.transactedBatchContext.Transaction, out context3))
{
if (this.IsOpen)
{
this.transactedBatchContext.ForceCommit();
return true;
}
this.transactedBatchContext.ForceRollback();
return false;
}
if (context3 == null)
{
this.transactedBatchContext.ForceRollback();
return false;
}
TransactionMessageProperty.Set(this.transactedBatchContext.Transaction, context3.RequestMessage);
this.transactedBatchContext.InDispatch = true;
if (!this.HandleRequest(context3, currentOperationContext))
{
return false;
}
if (this.transactedBatchContext.InDispatch)
{
this.transactedBatchContext.ForceRollback();
this.transactedBatchContext.InDispatch = false;
return true;
}
if (!this.TryAcquirePump())
{
return false;
}
currentOperationContext.Recycle();
}
}
finally
{
OperationContext.Current = current;
}
return true;
}