本文整理汇总了C#中System.ServiceModel.Dispatcher.MessageRpc.Pause方法的典型用法代码示例。如果您正苦于以下问题:C# MessageRpc.Pause方法的具体用法?C# MessageRpc.Pause怎么用?C# MessageRpc.Pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Dispatcher.MessageRpc
的用法示例。
在下文中一共展示了MessageRpc.Pause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindCore
private void BindCore(ref MessageRpc rpc, bool startOperation)
{
SynchronizationContext syncContext = this.GetSyncContext(rpc.InstanceContext);
if (syncContext != null)
{
IResumeMessageRpc state = rpc.Pause();
if (startOperation)
{
syncContext.OperationStarted();
syncContext.Post(this.ThreadAffinityStartCallbackDelegate, state);
}
else
{
syncContext.Post(this.ThreadAffinityEndCallbackDelegate, state);
}
}
else if (rpc.SwitchedThreads)
{
IResumeMessageRpc rpc3 = rpc.Pause();
ActionItem.Schedule(CleanThreadCallbackDelegate, rpc3);
}
}
示例2: LockInstance
internal void LockInstance(ref MessageRpc rpc)
{
if (this.mode != ConcurrencyMode.Multiple)
{
ConcurrencyInstanceContextFacet concurrency = rpc.InstanceContext.Concurrency;
lock (rpc.InstanceContext.ThisLock)
{
if (!concurrency.Locked)
{
concurrency.Locked = true;
}
else
{
MessageRpcWaiter waiter = new MessageRpcWaiter(rpc.Pause());
concurrency.EnqueueNewMessage(waiter);
}
}
if (this.mode == ConcurrencyMode.Reentrant)
{
rpc.OperationContext.IsServiceReentrant = true;
}
}
}
示例3: BeginReply
void BeginReply(ref MessageRpc rpc)
{
bool success = false;
try
{
IResumeMessageRpc resume = rpc.Pause();
rpc.AsyncResult = rpc.RequestContext.BeginReply(rpc.Reply, rpc.ReplyTimeoutHelper.RemainingTime(),
onReplyCompleted, resume);
success = true;
if (rpc.AsyncResult.CompletedSynchronously)
{
rpc.UnPause();
}
}
catch (CommunicationException e)
{
this.error.HandleError(e);
}
catch (TimeoutException e)
{
this.error.HandleError(e);
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
if (DiagnosticUtility.ShouldTraceError)
{
TraceUtility.TraceEvent(System.Diagnostics.TraceEventType.Error,
TraceCode.ServiceOperationExceptionOnReply,
SR.GetString(SR.TraceCodeServiceOperationExceptionOnReply),
this, e);
}
if (!this.error.HandleError(e))
{
rpc.RequestContextThrewOnReply = true;
rpc.CanSendReply = false;
}
}
finally
{
if (!success)
{
rpc.UnPause();
}
}
}
示例4: BeginFinalizeCorrelation
void BeginFinalizeCorrelation(ref MessageRpc rpc)
{
Message reply = rpc.Reply;
if (reply != null && rpc.Error == null)
{
if (rpc.transaction != null && rpc.transaction.Current != null &&
rpc.transaction.Current.TransactionInformation.Status != TransactionStatus.Active)
{
return;
}
CorrelationCallbackMessageProperty callback;
if (CorrelationCallbackMessageProperty.TryGet(reply, out callback))
{
if (callback.IsFullyDefined)
{
bool success = false;
try
{
rpc.RequestContextThrewOnReply = true;
rpc.CorrelationCallback = callback;
IResumeMessageRpc resume = rpc.Pause();
rpc.AsyncResult = rpc.CorrelationCallback.BeginFinalizeCorrelation(reply,
rpc.ReplyTimeoutHelper.RemainingTime(), onFinalizeCorrelationCompleted, resume);
success = true;
if (rpc.AsyncResult.CompletedSynchronously)
{
rpc.UnPause();
}
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
if (!this.error.HandleError(e))
{
rpc.CorrelationCallback = null;
rpc.CanSendReply = false;
}
}
finally
{
if (!success)
{
rpc.UnPause();
}
}
}
else
{
rpc.CorrelationCallback = new RpcCorrelationCallbackMessageProperty(callback, this, ref rpc);
reply.Properties[CorrelationCallbackMessageProperty.Name] = rpc.CorrelationCallback;
}
}
}
}
示例5: AcquireDynamicInstanceContextCore
bool AcquireDynamicInstanceContextCore(ref MessageRpc rpc)
{
bool success = rpc.InstanceContext.QuotaThrottle.Acquire(rpc.Pause());
if (success)
{
rpc.UnPause();
}
return success;
}
示例6: AcknowledgementCompleteAsyncResult
public AcknowledgementCompleteAsyncResult(
ReceiveContext receiveContext,
TimeSpan timeout,
ref MessageRpc rpc,
Transaction transaction,
AsyncCallback callback,
object state) : base(callback, state)
{
this.receiveContext = receiveContext;
this.currentTransaction = transaction;
this.channelHandler = rpc.channelHandler;
this.resumableRPC = rpc.Pause();
bool completeThrew = true;
try
{
bool completed = this.Complete(timeout);
completeThrew = false;
if (completed)
{
this.resumableRPC = null;
rpc.UnPause();
this.Complete(true);
}
}
finally
{
if (completeThrew)
{
rpc.UnPause();
}
}
}
示例7: InvokeBegin
internal void InvokeBegin(ref MessageRpc rpc)
{
if (rpc.Error == null)
{
try
{
this.InitializeCallContext(ref rpc);
object target = rpc.Instance;
this.DeserializeInputs(ref rpc);
this.InspectInputs(ref rpc);
ValidateMustUnderstand(ref rpc);
IAsyncResult result = null;
IDisposable impersonationContext = null;
IPrincipal originalPrincipal = null;
bool isThreadPrincipalSet = false;
bool isConcurrent = this.Parent.IsConcurrent(ref rpc);
try
{
if (this.parent.RequireClaimsPrincipalOnOperationContext)
{
SetClaimsPrincipalToOperationContext(rpc);
}
if (this.parent.SecurityImpersonation != null)
{
this.parent.SecurityImpersonation.StartImpersonation(ref rpc, out impersonationContext, out originalPrincipal, out isThreadPrincipalSet);
}
IManualConcurrencyOperationInvoker manualInvoker = this.Invoker as IManualConcurrencyOperationInvoker;
if (this.isSynchronous)
{
if (manualInvoker != null && isConcurrent)
{
if (this.bufferedReceiveEnabled)
{
rpc.OperationContext.IncomingMessageProperties.Add(
BufferedReceiveMessageProperty.Name, new BufferedReceiveMessageProperty(ref rpc));
}
rpc.ReturnParameter = manualInvoker.Invoke(target, rpc.InputParameters, rpc.InvokeNotification, out rpc.OutputParameters);
}
else
{
rpc.ReturnParameter = this.Invoker.Invoke(target, rpc.InputParameters, out rpc.OutputParameters);
}
}
else
{
bool isBeginSuccessful = false;
if (manualInvoker != null && isConcurrent && this.bufferedReceiveEnabled)
{
// This will modify the rpc, it has to be done before rpc.Pause
// since IResumeMessageRpc implementation keeps reference of rpc.
// This is to ensure consistent rpc whether or not InvokeBegin completed
// synchronously or asynchronously.
rpc.OperationContext.IncomingMessageProperties.Add(
BufferedReceiveMessageProperty.Name, new BufferedReceiveMessageProperty(ref rpc));
}
IResumeMessageRpc resumeRpc = rpc.Pause();
try
{
if (manualInvoker != null && isConcurrent)
{
result = manualInvoker.InvokeBegin(target, rpc.InputParameters, rpc.InvokeNotification, invokeCallback, resumeRpc);
}
else
{
result = this.Invoker.InvokeBegin(target, rpc.InputParameters, invokeCallback, resumeRpc);
}
isBeginSuccessful = true;
// if the call above actually went async, then responsibility to call
// ProcessMessage{6,7,Cleanup} has been transferred to InvokeCallback
}
finally
{
if (!isBeginSuccessful)
{
rpc.UnPause();
}
}
}
}
finally
{
try
{
if (this.parent.SecurityImpersonation != null)
{
this.parent.SecurityImpersonation.StopImpersonation(ref rpc, impersonationContext, originalPrincipal, isThreadPrincipalSet);
}
}
#pragma warning suppress 56500 // covered by FxCOP
catch
{
string message = null;
//.........这里部分代码省略.........
示例8: BeginReply
private void BeginReply(ref MessageRpc rpc)
{
bool success = false;
try
{
IResumeMessageRpc resume = rpc.Pause();
rpc.AsyncResult = rpc.RequestContext.BeginReply(rpc.Reply, rpc.ReplyTimeoutHelper.RemainingTime(),
s_onReplyCompleted, resume);
success = true;
if (rpc.AsyncResult.CompletedSynchronously)
{
rpc.UnPause();
}
}
catch (CommunicationException e)
{
_error.HandleError(e);
}
catch (TimeoutException e)
{
_error.HandleError(e);
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
if (!_error.HandleError(e))
{
rpc.RequestContextThrewOnReply = true;
rpc.CanSendReply = false;
}
}
finally
{
if (!success)
{
rpc.UnPause();
}
}
}
示例9: InvokeBegin
internal void InvokeBegin(ref MessageRpc rpc)
{
if (rpc.Error == null)
{
object target = rpc.Instance;
this.DeserializeInputs(ref rpc);
this.InspectInputs(ref rpc);
ValidateMustUnderstand(ref rpc);
IAsyncResult result;
bool isBeginSuccessful = false;
IResumeMessageRpc resumeRpc = rpc.Pause();
try
{
result = Invoker.InvokeBegin(target, rpc.InputParameters, invokeCallback, resumeRpc);
isBeginSuccessful = true;
}
finally
{
if (!isBeginSuccessful)
{
rpc.UnPause();
}
}
if (result == null)
{
throw TraceUtility.ThrowHelperError(new ArgumentNullException("IOperationInvoker.BeginDispatch"),
rpc.Request);
}
if (result.CompletedSynchronously)
{
// if the async call completed synchronously, then the responsibility to call
// ProcessMessage{6,7,Cleanup} still remains on this thread
rpc.UnPause();
rpc.AsyncResult = result;
}
}
}
示例10: SetCurrent
internal void SetCurrent(ref MessageRpc rpc)
{
Transaction current = rpc.Transaction.Current;
if (current == null)
{
DiagnosticUtility.FailFast("we should never get here with a requestTransaction null");
}
lock (this.mutex)
{
if (this.current == null)
{
this.current = current;
}
else if (this.current != current)
{
this.waiting = current;
this.paused = rpc.Pause();
}
else
{
rpc.Transaction.Current = this.current;
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:TransactionInstanceContextFacet.cs
示例11: SetCurrent
// ........................................................................................................
internal void SetCurrent(ref MessageRpc rpc)
{
Transaction requestTransaction = rpc.Transaction.Current;
if (!(requestTransaction != null))
{
// tx processing requires failfast when state is inconsistent
DiagnosticUtility.FailFast("we should never get here with a requestTransaction null");
}
lock (this.mutex)
{
if (this.current == null)
{
this.current = requestTransaction;
}
else if (this.current != requestTransaction)
{
this.waiting = requestTransaction;
this.paused = rpc.Pause();
}
else
{
rpc.Transaction.Current = this.current; //rpc.Transaction.Current should get the dependent clone
}
}
}
示例12: InvokeBegin
internal void InvokeBegin(ref MessageRpc rpc)
{
if (rpc.Error == null)
{
try
{
this.InitializeCallContext(ref rpc);
object instance = rpc.Instance;
this.DeserializeInputs(ref rpc);
this.InspectInputs(ref rpc);
this.ValidateMustUnderstand(ref rpc);
IAsyncResult result = null;
IDisposable impersonationContext = null;
IPrincipal originalPrincipal = null;
bool isThreadPrincipalSet = false;
bool flag2 = this.Parent.IsConcurrent(ref rpc);
try
{
if (this.parent.SecurityImpersonation != null)
{
this.parent.SecurityImpersonation.StartImpersonation(ref rpc, out impersonationContext, out originalPrincipal, out isThreadPrincipalSet);
}
IManualConcurrencyOperationInvoker invoker = this.Invoker as IManualConcurrencyOperationInvoker;
if (this.isSynchronous)
{
if ((invoker != null) && flag2)
{
if (this.bufferedReceiveEnabled)
{
rpc.OperationContext.IncomingMessageProperties.Add(BufferedReceiveMessageProperty.Name, new BufferedReceiveMessageProperty(ref rpc));
}
rpc.ReturnParameter = invoker.Invoke(instance, rpc.InputParameters, rpc.InvokeNotification, out rpc.OutputParameters);
}
else
{
rpc.ReturnParameter = this.Invoker.Invoke(instance, rpc.InputParameters, out rpc.OutputParameters);
}
}
else
{
bool flag3 = false;
if (((invoker != null) && flag2) && this.bufferedReceiveEnabled)
{
rpc.OperationContext.IncomingMessageProperties.Add(BufferedReceiveMessageProperty.Name, new BufferedReceiveMessageProperty(ref rpc));
}
IResumeMessageRpc state = rpc.Pause();
try
{
if ((invoker != null) && flag2)
{
result = invoker.InvokeBegin(instance, rpc.InputParameters, rpc.InvokeNotification, invokeCallback, state);
}
else
{
result = this.Invoker.InvokeBegin(instance, rpc.InputParameters, invokeCallback, state);
}
flag3 = true;
}
finally
{
if (!flag3)
{
rpc.UnPause();
}
}
}
}
finally
{
try
{
if (this.parent.SecurityImpersonation != null)
{
this.parent.SecurityImpersonation.StopImpersonation(ref rpc, impersonationContext, originalPrincipal, isThreadPrincipalSet);
}
}
catch
{
string message = null;
try
{
message = System.ServiceModel.SR.GetString("SFxRevertImpersonationFailed0");
}
finally
{
DiagnosticUtility.FailFast(message);
}
}
}
if (this.isSynchronous)
{
this.InspectOutputs(ref rpc);
this.SerializeOutputs(ref rpc);
}
else
{
if (result == null)
{
throw TraceUtility.ThrowHelperError(new ArgumentNullException("IOperationInvoker.BeginDispatch"), rpc.Request);
}
//.........这里部分代码省略.........
示例13: BeginReply
private void BeginReply(ref MessageRpc rpc)
{
bool flag = false;
try
{
IResumeMessageRpc state = rpc.Pause();
rpc.AsyncResult = rpc.RequestContext.BeginReply(rpc.Reply, rpc.ReplyTimeoutHelper.RemainingTime(), onReplyCompleted, state);
flag = true;
if (rpc.AsyncResult.CompletedSynchronously)
{
rpc.UnPause();
}
}
catch (CommunicationException exception)
{
this.error.HandleError(exception);
}
catch (TimeoutException exception2)
{
this.error.HandleError(exception2);
}
catch (Exception exception3)
{
if (Fx.IsFatal(exception3))
{
throw;
}
if (DiagnosticUtility.ShouldTraceError)
{
TraceUtility.TraceEvent(TraceEventType.Error, 0x80034, System.ServiceModel.SR.GetString("TraceCodeServiceOperationExceptionOnReply"), this, exception3);
}
if (!this.error.HandleError(exception3))
{
rpc.RequestContextThrewOnReply = true;
rpc.CanSendReply = false;
}
}
finally
{
if (!flag)
{
rpc.UnPause();
}
}
}
示例14: BeginFinalizeCorrelation
private void BeginFinalizeCorrelation(ref MessageRpc rpc)
{
CorrelationCallbackMessageProperty property;
Message reply = rpc.Reply;
if ((((reply != null) && (rpc.Error == null)) && (((rpc.transaction == null) || (rpc.transaction.Current == null)) || (rpc.transaction.Current.TransactionInformation.Status == TransactionStatus.Active))) && CorrelationCallbackMessageProperty.TryGet(reply, out property))
{
if (property.IsFullyDefined)
{
bool flag = false;
try
{
try
{
rpc.RequestContextThrewOnReply = true;
rpc.CorrelationCallback = property;
IResumeMessageRpc state = rpc.Pause();
rpc.AsyncResult = rpc.CorrelationCallback.BeginFinalizeCorrelation(reply, rpc.ReplyTimeoutHelper.RemainingTime(), onFinalizeCorrelationCompleted, state);
flag = true;
if (rpc.AsyncResult.CompletedSynchronously)
{
rpc.UnPause();
}
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
if (!this.error.HandleError(exception))
{
rpc.CorrelationCallback = null;
rpc.CanSendReply = false;
}
}
return;
}
finally
{
if (!flag)
{
rpc.UnPause();
}
}
}
rpc.CorrelationCallback = new RpcCorrelationCallbackMessageProperty(property, this, ref rpc);
reply.Properties[CorrelationCallbackMessageProperty.Name] = rpc.CorrelationCallback;
}
}
示例15: AcquireDynamicInstanceContextCore
private bool AcquireDynamicInstanceContextCore(ref MessageRpc rpc)
{
bool flag = rpc.InstanceContext.QuotaThrottle.Acquire(rpc.Pause());
if (flag)
{
rpc.UnPause();
}
return flag;
}