当前位置: 首页>>代码示例>>C#>>正文


C# OperationContext.Recycle方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:ChannelHandler.cs

示例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;
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:65,代码来源:ChannelHandler.cs

示例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;
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:36,代码来源:ChannelHandler.cs

示例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;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:ChannelHandler.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:57,代码来源:ChannelHandler.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:86,代码来源:ChannelHandler.cs


注:本文中的System.ServiceModel.OperationContext.Recycle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。