本文整理汇总了C#中CommunicationState类的典型用法代码示例。如果您正苦于以下问题:C# CommunicationState类的具体用法?C# CommunicationState怎么用?C# CommunicationState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommunicationState类属于命名空间,在下文中一共展示了CommunicationState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:caesay,项目名称:NearSight,代码行数:27,代码来源:CommunicationObject.cs
示例2: Close
public override void Close(TimeSpan timeout)
{
lock (thisLock)
{
this.state = CommunicationState.Closed;
}
}
开发者ID:dmetzgar,项目名称:custom-transport-channel,代码行数:7,代码来源:FileRequestContext.cs
示例3: ConnectionState
public ConnectionState(int instanceId, ProxyState proxyState, CommunicationState commState, string proxyType)
{
this.InstanceId = instanceId;
this.ProxyState = proxyState;
this.CommState = commState;
this.ProxyType = proxyType;
}
开发者ID:willr,项目名称:WcfMonitoringProxy,代码行数:7,代码来源:ConnectionState.cs
示例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.");
}
开发者ID:boskomijin,项目名称:SGApp,代码行数:9,代码来源:SGServiceHostTest.cs
示例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();
}
开发者ID:dmetzgar,项目名称:custom-transport-channel,代码行数:9,代码来源:FileRequestContext.cs
示例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;
}
开发者ID:uQr,项目名称:referencesource,代码行数:9,代码来源:RequestContextBase.cs
示例7: ToGameClient
public ToGameClient(SilverSocket socket)
{
_socket = socket;
{
socket.OnDataArrivalEvent += DataArrival;
socket.OnSocketClosedEvent += OnSocketClosed;
}
_communicationState = CommunicationState.VerifyGame;
}
开发者ID:Ryuuke,项目名称:SilverDofus,代码行数:10,代码来源:ToGameClient.cs
示例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);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:SharedConnectionListener.cs
示例9: Abort
public override void Abort()
{
lock (thisLock)
{
if (this.aborted)
{
return;
}
this.aborted = true;
this.state = CommunicationState.Faulted;
}
}
开发者ID:dmetzgar,项目名称:custom-transport-channel,代码行数:12,代码来源:FileRequestContext.cs
示例10: Abort
public override void Abort()
{
lock (_aLock)
{
if (_aborted)
{
return;
}
_aborted = true;
_state = CommunicationState.Faulted;
}
}
开发者ID:shaunxu,项目名称:roma,代码行数:12,代码来源:MessageBusRequestContext.cs
示例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();
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:13,代码来源:MsmqBindingMonitor.cs
示例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;
}
开发者ID:shaunxu,项目名称:roma,代码行数:16,代码来源:MessageBusRequestContext.cs
示例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;
}
开发者ID:knunery,项目名称:wcf-perf-test,代码行数:16,代码来源:AppDomainHost.cs
示例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.");
}
}
}
开发者ID:yuriik83,项目名称:workstation-uaclient,代码行数:49,代码来源:CommunicationObject.cs
示例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();
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:SharedConnectionListener.cs
示例16: Abort
public void Abort()
{
lock (this.ThisLock)
{
if (this.aborted || (this.state == CommunicationState.Closed))
{
return;
}
this.aborted = true;
this.state = CommunicationState.Closing;
}
if (DiagnosticUtility.ShouldTraceInformation)
{
TraceUtility.TraceEvent(TraceEventType.Information, 0x80002, System.ServiceModel.SR.GetString("TraceCodeCommunicationObjectAborted", new object[] { TraceUtility.CreateSourceString(this) }), this);
}
bool flag = true;
try
{
this.OnClosing();
if (!this.onClosingCalled)
{
throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosing"), Guid.Empty, this);
}
this.OnAbort();
this.OnClosed();
if (!this.onClosedCalled)
{
throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosed"), Guid.Empty, this);
}
flag = false;
}
finally
{
if (flag && DiagnosticUtility.ShouldTraceWarning)
{
TraceUtility.TraceEvent(TraceEventType.Warning, 0x80003, System.ServiceModel.SR.GetString("TraceCodeCommunicationObjectAbortFailed", new object[] { this.GetCommunicationObjectType().ToString() }), this);
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:CommunicationObject.cs
示例17: Parse
public void Parse(string inputBuffer, CommunicationState communicationState)
{
if (communicationState == CommunicationState.Open)
{
if (inputBuffer.Contains("Y"))
{
NotifyLogData(communicationState, null);
}
}
else if (communicationState == CommunicationState.Reading)
{
var charAry = inputBuffer.Split(' ');
List<string > lst = new List<string>();
foreach (var s in charAry)
{
if(!string.IsNullOrWhiteSpace(s))
lst.Add(s);
}
AddToReading(lst);
}
}
开发者ID:randmfun,项目名称:ThirdEye,代码行数:23,代码来源:ScanDataParser.cs
示例18: Close
public void Close(TimeSpan timeout)
{
if (timeout < TimeSpan.Zero)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new ArgumentOutOfRangeException("timeout", SR.GetString(SR.SFxTimeoutOutOfRange0)));
using (DiagnosticUtility.ShouldUseActivity && this.TraceOpenAndClose ? this.CreateCloseActivity() : null)
{
CommunicationState originalState;
lock (ThisLock)
{
originalState = this.state;
#if DEBUG
if (closeStack == null)
closeStack = new StackTrace();
#endif
if (originalState != CommunicationState.Closed)
this.state = CommunicationState.Closing;
this.closeCalled = true;
}
switch (originalState)
{
case CommunicationState.Created:
case CommunicationState.Opening:
case CommunicationState.Faulted:
this.Abort();
if (originalState == CommunicationState.Faulted)
{
throw TraceUtility.ThrowHelperError(this.CreateFaultedException(), Guid.Empty, this);
}
break;
case CommunicationState.Opened:
{
bool throwing = true;
try
{
TimeoutHelper actualTimeout = new TimeoutHelper(timeout);
OnClosing();
if (!this.onClosingCalled)
throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosing"), Guid.Empty, this);
OnClose(actualTimeout.RemainingTime());
OnClosed();
if (!this.onClosedCalled)
throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosed"), Guid.Empty, this);
throwing = false;
}
finally
{
if (throwing)
{
if (DiagnosticUtility.ShouldTraceWarning)
{
TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.CommunicationObjectCloseFailed, SR.GetString(SR.TraceCodeCommunicationObjectCloseFailed, this.GetCommunicationObjectType().ToString()), this);
}
Abort();
}
}
break;
}
case CommunicationState.Closing:
case CommunicationState.Closed:
break;
default:
throw Fx.AssertAndThrow("CommunicationObject.BeginClose: Unknown CommunicationState");
}
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:78,代码来源:CommunicationObject.cs
示例19: BeginOpen
public IAsyncResult BeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
{
if (timeout < TimeSpan.Zero)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new ArgumentOutOfRangeException("timeout", SR.GetString(SR.SFxTimeoutOutOfRange0)));
lock (ThisLock)
{
ThrowIfDisposedOrImmutable();
this.state = CommunicationState.Opening;
}
bool throwing = true;
try
{
OnOpening();
if (!this.onOpeningCalled)
throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnOpening"), Guid.Empty, this);
IAsyncResult result = new OpenAsyncResult(this, timeout, callback, state);
throwing = false;
return result;
}
finally
{
if (throwing)
{
if (DiagnosticUtility.ShouldTraceWarning)
{
TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.CommunicationObjectOpenFailed, SR.GetString(SR.TraceCodeCommunicationObjectOpenFailed, this.GetCommunicationObjectType().ToString()), this);
}
Fault();
}
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:36,代码来源:CommunicationObject.cs
示例20: OnOpenedAsync
/// <summary>
/// Invoked during the transition of a communication object into the opened 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>
protected virtual async Task OnOpenedAsync(CancellationToken token = default(CancellationToken))
{
this.onOpenedCalled = true;
await this.semaphore.WaitAsync(token).ConfigureAwait(false);
try
{
if (this.aborted || this.State != CommunicationState.Opening)
{
return;
}
this.State = CommunicationState.Opened;
}
finally
{
this.semaphore.Release();
}
Log.Info($"{this.GetType().Name} opened.");
EventHandler opened = this.Opened;
if (opened != null)
{
opened(this, EventArgs.Empty);
}
}
开发者ID:yuriik83,项目名称:workstation-uaclient,代码行数:30,代码来源:CommunicationObject.cs
注:本文中的CommunicationState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论