本文整理汇总了C#中CommunicationState类的典型用法代码示例。如果您正苦于以下问题:C# CommunicationState类的具体用法?C# CommunicationState怎么用?C# CommunicationState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommunicationState类属于命名空间,在下文中一共展示了CommunicationState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetState
protected virtual void SetState(CommunicationState state)
{
State = state;
switch (state)
{
case CommunicationState.Created:
break;
case CommunicationState.Opening:
Opening?.Invoke(this, new EventArgs());
break;
case CommunicationState.Opened:
Opened?.Invoke(this, new EventArgs());
break;
case CommunicationState.Closing:
Closing?.Invoke(this, new EventArgs());
break;
case CommunicationState.Closed:
Closed?.Invoke(this, new EventArgs());
break;
case CommunicationState.Faulted:
Faulted?.Invoke(this, new EventArgs());
break;
default:
throw new ArgumentOutOfRangeException(nameof(state), state, null);
}
StateChanged?.Invoke(this, new EventArgs());
}
示例2: Close
public override void Close(TimeSpan timeout)
{
lock (thisLock)
{
this.state = CommunicationState.Closed;
}
}
示例3: ConnectionState
public ConnectionState(int instanceId, ProxyState proxyState, CommunicationState commState, string proxyType)
{
this.InstanceId = instanceId;
this.ProxyState = proxyState;
this.CommState = commState;
this.ProxyType = proxyType;
}
示例4: GetStateTest
public void GetStateTest()
{
SGServiceHost target = new SGServiceHost(); // TODO: Initialize to an appropriate value
CommunicationState expected = new CommunicationState(); // TODO: Initialize to an appropriate value
CommunicationState actual;
actual = target.GetState();
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
示例5: FileRequestContext
public FileRequestContext(Message message, FileReplyChannel parent)
{
this.aborted = false;
this.message = message;
this.parent = parent;
this.state = CommunicationState.Opened;
this.thisLock = new object();
this.writeLock = new object();
}
示例6: ReInitialize
public void ReInitialize(Message requestMessage)
{
this.state = CommunicationState.Opened;
this.requestMessageException = null;
this.replySent = false;
this.replyInitiated = false;
this.aborted = false;
this.requestMessage = requestMessage;
}
示例7: ToGameClient
public ToGameClient(SilverSocket socket)
{
_socket = socket;
{
socket.OnDataArrivalEvent += DataArrival;
socket.OnSocketClosedEvent += OnSocketClosed;
}
_communicationState = CommunicationState.VerifyGame;
}
示例8: SharedConnectionListener
internal SharedConnectionListener(BaseUriWithWildcard baseAddress, int queueId, Guid token, Func<Uri, int> onDuplicatedViaCallback)
{
this.baseAddress = baseAddress;
this.queueId = queueId;
this.token = token;
this.onDuplicatedViaCallback = onDuplicatedViaCallback;
this.connectionQueue = TraceUtility.CreateInputQueue<DuplicateConnectionAsyncResult>();
this.state = CommunicationState.Created;
this.reconnectEvent = new ManualResetEvent(true);
this.StartListen(false);
}
示例9: Abort
public override void Abort()
{
lock (thisLock)
{
if (this.aborted)
{
return;
}
this.aborted = true;
this.state = CommunicationState.Faulted;
}
}
示例10: Abort
public override void Abort()
{
lock (_aLock)
{
if (_aborted)
{
return;
}
_aborted = true;
_state = CommunicationState.Faulted;
}
}
示例11: Open
public void Open()
{
lock (this.thisLock)
{
if (this.currentState != CommunicationState.Created)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CommunicationObjectCannotBeModified, this.GetType().ToString())));
}
this.currentState = CommunicationState.Opened;
this.ScheduleRetryTimerIfNotSet();
}
}
示例12: MessageBusRequestContext
public MessageBusRequestContext(
Message message, MessageBusReplyChannel parent,
EndpointAddress address,
IBus bus,
string relatedTo)
{
_aborted = false;
_parent = parent;
_message = message;
_address = address;
_busMessageId = relatedTo;
_bus = bus;
_aLock = new object();
_state = CommunicationState.Opened;
}
示例13: AppDomainHost
protected AppDomainHost(Type serviceType,AppDomain appDomain,PermissionSet permissions,Uri[] baseAddresses)
{
State = CommunicationState.Faulted;
//Cannot grant service permissions the host does not have
permissions.Demand();
string assemblyName = Assembly.GetAssembly(typeof(ServiceHostActivator)).FullName;
m_ServiceHostActivator = appDomain.CreateInstanceAndUnwrap(assemblyName,typeof(ServiceHostActivator).ToString()) as ServiceHostActivator;
appDomain.SetPermissionsSet(permissions);
m_ServiceHostActivator.CreateHost(serviceType,baseAddresses);
State = CommunicationState.Created;
}
示例14: AbortAsync
/// <summary>
/// Causes a communication object to transition immediately from its current state into the closing state.
/// </summary>
/// <param name="token">The <see cref="T:ConverterSystems.Threading.CancellationToken" /> that notifies when the task should be canceled.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public async Task AbortAsync(CancellationToken token = default(CancellationToken))
{
await this.semaphore.WaitAsync(token).ConfigureAwait(false);
try
{
if (this.aborted || this.State == CommunicationState.Closed)
{
return;
}
this.aborted = true;
this.State = CommunicationState.Closing;
}
finally
{
this.semaphore.Release();
}
bool flag2 = true;
try
{
await this.OnClosingAsync(token).ConfigureAwait(false);
if (!this.onClosingCalled)
{
throw new InvalidOperationException($"{this.GetType().Name}.OnClosingAsync did not call await base.OnClosingAsync");
}
await this.OnAbortAsync(token).ConfigureAwait(false);
await this.OnClosedAsync(token).ConfigureAwait(false);
if (!this.onClosedCalled)
{
throw new InvalidOperationException($"{this.GetType().Name}.OnClosedAsync did not call await base.OnClosedAsync");
}
flag2 = false;
}
finally
{
if (flag2)
{
Log.Warn($"{this.GetType().Name}.AbortAsync failed.");
}
}
}
示例15: Close
private void Close()
{
lock (this.ThisLock)
{
if (this.state == CommunicationState.Closed)
{
return;
}
this.state = CommunicationState.Closed;
}
if (this.connectionQueue != null)
{
this.connectionQueue.Close();
}
if (this.reconnectEvent != null)
{
this.reconnectEvent.Close();
}
}