本文整理汇总了C#中TimerEx类的典型用法代码示例。如果您正苦于以下问题:C# TimerEx类的具体用法?C# TimerEx怎么用?C# TimerEx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimerEx类属于命名空间,在下文中一共展示了TimerEx类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SIP_UA_Registration
/// <summary>
/// Default constructor.
/// </summary>
/// <param name="stack">Owner SIP stack.</param>
/// <param name="server">Registrar server URI. For example: sip:domain.com.</param>
/// <param name="aor">Address of record. For example: [email protected]</param>
/// <param name="contact">Contact URI.</param>
/// <param name="expires">Gets after how many seconds reigisration expires.</param>
/// <exception cref="ArgumentNullException">Is raised when <b>ua</b>,<b>server</b>,<b>transport</b>,<b>aor</b> or <b>contact</b> is null reference.</exception>
/// <exception cref="ArgumentException">Is raised when any of the arguments contains invalid value.</exception>
internal SIP_UA_Registration(SIP_Stack stack,SIP_Uri server,string aor,AbsoluteUri contact,int expires)
{
if(stack == null){
throw new ArgumentNullException("stack");
}
if(server == null){
throw new ArgumentNullException("server");
}
if(aor == null){
throw new ArgumentNullException("aor");
}
if(aor == string.Empty){
throw new ArgumentException("Argument 'aor' value must be specified.");
}
if(contact == null){
throw new ArgumentNullException("contact");
}
m_pStack = stack;
m_pServer = server;
m_AOR = aor;
m_pContact = contact;
m_RefreshInterval = expires;
m_pContacts = new List<AbsoluteUri>();
m_pTimer = new TimerEx((m_RefreshInterval - 15) * 1000);
m_pTimer.AutoReset = false;
m_pTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimer_Elapsed);
m_pTimer.Enabled = false;
}
示例2: DNS_ClientCache
/// <summary>
/// Default constructor.
/// </summary>
internal DNS_ClientCache()
{
m_pCache = new Dictionary<string,CacheEntry>();
m_pTimerTimeout = new TimerEx(60000);
m_pTimerTimeout.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimerTimeout_Elapsed);
m_pTimerTimeout.Start();
}
示例3: SIP_FlowManager
/// <summary>
/// Default constructor.
/// </summary>
/// <param name="owner">Owner transport layer.</param>
/// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
internal SIP_FlowManager(SIP_TransportLayer owner)
{
if(owner == null){
throw new ArgumentNullException("owner");
}
m_pOwner = owner;
m_pFlows = new Dictionary<string,SIP_Flow>();
m_pTimeoutTimer = new TimerEx(15000);
m_pTimeoutTimer.AutoReset = true;
m_pTimeoutTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimeoutTimer_Elapsed);
m_pTimeoutTimer.Enabled = true;
}
示例4: DNS_ClientTransaction
/// <summary>
/// Default constructor.
/// </summary>
/// <param name="owner">Owner DNS client.</param>
/// <param name="id">Transaction ID.</param>
/// <param name="qtype">QTYPE value.</param>
/// <param name="qname">QNAME value.</param>
/// <param name="timeout">Timeout in milliseconds.</param>
/// <exception cref="ArgumentNullException">Is raised when <b>owner</b> or <b>qname</b> is null reference.</exception>
internal DNS_ClientTransaction(Dns_Client owner,int id,DNS_QType qtype,string qname,int timeout)
{
if(owner == null){
throw new ArgumentNullException("owner");
}
if(qname == null){
throw new ArgumentNullException("qname");
}
m_pOwner = owner;
m_ID = id;
m_QName = qname;
m_QType = qtype;
m_CreateTime = DateTime.Now;
m_pTimeoutTimer = new TimerEx(timeout);
m_pTimeoutTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimeoutTimer_Elapsed);
}
示例5: UacInvite2xxRetransmissionWaiter
/// <summary>
/// Default constructor.
/// </summary>
/// <param name="dialog">Owner INVITE dialog.</param>
/// <param name="invite">INVITE request which 2xx retransmission to wait.</param>
/// <exception cref="ArgumentNullException">Is raised when <b>dialog</b> or <b>invite</b> is null reference.</exception>
public UacInvite2xxRetransmissionWaiter(SIP_Dialog_Invite dialog, SIP_Request invite)
{
if (dialog == null)
{
throw new ArgumentNullException("dialog");
}
if (invite == null)
{
throw new ArgumentNullException("invite");
}
m_pDialog = dialog;
m_pInvite = invite;
/* RFC 3261 13.2.2.4.
The UAC core considers the INVITE transaction completed 64*T1 seconds
after the reception of the first 2xx response.
*/
m_pTimer = new TimerEx(64*SIP_TimerConstants.T1, false);
m_pTimer.Elapsed += m_pTimer_Elapsed;
m_pTimer.Enabled = true;
}
示例6: RTP_Session
/// <summary>
/// Default constructor.
/// </summary>
/// <param name="session">Owner RTP multimedia session.</param>
/// <param name="localEP">Local RTP end point.</param>
/// <param name="clock">RTP media clock.</param>
/// <exception cref="ArgumentNullException">Is raised when <b>localEP</b>, <b>localEP</b> or <b>clock</b> is null reference.</exception>
internal RTP_Session(RTP_MultimediaSession session, RTP_Address localEP, RTP_Clock clock)
{
if (session == null)
{
throw new ArgumentNullException("session");
}
if (localEP == null)
{
throw new ArgumentNullException("localEP");
}
if (clock == null)
{
throw new ArgumentNullException("clock");
}
m_pSession = session;
m_pLocalEP = localEP;
m_pRtpClock = clock;
m_pRtpReceiveBuffer = new byte[Workaround.Definitions.MaxStreamLineLength];
m_pRtcpReceiveBuffer = new byte[Workaround.Definitions.MaxStreamLineLength];
m_pLocalSources = new List<RTP_Source_Local>();
m_pTargets = new List<RTP_Address>();
m_pMembers = new Dictionary<uint, RTP_Source>();
m_pSenders = new Dictionary<uint, RTP_Source>();
m_pConflictingEPs = new Dictionary<string, DateTime>();
m_pRtpSocket = new Socket(localEP.IP.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
m_pRtpSocket.Bind(localEP.RtpEP);
m_pRtcpSocket = new Socket(localEP.IP.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
m_pRtcpSocket.Bind(localEP.RtcpEP);
m_pRtcpTimer = new TimerEx();
m_pRtcpTimer.Elapsed += delegate { SendRtcp(); };
m_pRtcpTimer.AutoReset = false;
}
示例7: TCP_Client
/// <summary>
/// Default constructor.
/// </summary>
public TCP_Client()
{
m_pTimer_IdleTimeout = new TimerEx(30000, true);
m_pTimer_IdleTimeout.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimer_IdleTimeout_Elapsed);
}
示例8: IDLE
private bool IDLE(string cmdTag,string cmdText)
{
/* RFC 2177 3. IDLE Command.
Arguments: none
Responses: continuation data will be requested; the client sends
the continuation data "DONE" to end the command
Result: OK - IDLE completed after client sent "DONE"
NO - failure: the server will not allow the IDLE
command at this time
BAD - command unknown or arguments invalid
The IDLE command may be used with any IMAP4 server implementation
that returns "IDLE" as one of the supported capabilities to the
CAPABILITY command. If the server does not advertise the IDLE
capability, the client MUST NOT use the IDLE command and must poll
for mailbox updates. In particular, the client MUST continue to be
able to accept unsolicited untagged responses to ANY command, as
specified in the base IMAP specification.
The IDLE command is sent from the client to the server when the
client is ready to accept unsolicited mailbox update messages. The
server requests a response to the IDLE command using the continuation
("+") response. The IDLE command remains active until the client
responds to the continuation, and as long as an IDLE command is
active, the server is now free to send untagged EXISTS, EXPUNGE, and
other messages at any time.
The IDLE command is terminated by the receipt of a "DONE"
continuation from the client; such response satisfies the server's
continuation request. At that point, the server MAY send any
remaining queued untagged responses and then MUST immediately send
the tagged response to the IDLE command and prepare to process other
commands. As in the base specification, the processing of any new
command may cause the sending of unsolicited untagged responses,
subject to the ambiguity limitations. The client MUST NOT send a
command while the server is waiting for the DONE, since the server
will not be able to distinguish a command from a continuation.
The server MAY consider a client inactive if it has an IDLE command
running, and if such a server has an inactivity timeout it MAY log
the client off implicitly at the end of its timeout period. Because
of that, clients using IDLE are advised to terminate the IDLE and
re-issue it at least every 29 minutes to avoid being logged off.
This still allows a client to receive immediate mailbox updates even
though it need only "poll" at half hour intervals.
Example: C: A001 SELECT INBOX
S: * FLAGS (Deleted Seen)
S: * 3 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1]
S: A001 OK SELECT completed
C: A002 IDLE
S: + idling
...time passes; new mail arrives...
S: * 4 EXISTS
C: DONE
S: A002 OK IDLE terminated
...another client expunges message 2 now...
C: A003 FETCH 4 ALL
S: * 4 FETCH (...)
S: A003 OK FETCH completed
C: A004 IDLE
S: * 2 EXPUNGE
S: * 3 EXISTS
S: + idling
...time passes; another client expunges message 3...
S: * 3 EXPUNGE
S: * 2 EXISTS
...time passes; new mail arrives...
S: * 3 EXISTS
C: DONE
S: A004 OK IDLE terminated
C: A005 FETCH 3 ALL
S: * 3 FETCH (...)
S: A005 OK FETCH completed
*/
if(!this.IsAuthenticated){
m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"NO","Authentication required."));
return true;
}
m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus("+","idling"));
TimerEx timer = new TimerEx(30000,true);
timer.Elapsed += new System.Timers.ElapsedEventHandler(delegate(object sender,System.Timers.ElapsedEventArgs e){
try{
UpdateSelectedFolderAndSendChanges();
}
catch{
}
});
timer.Enabled = true;
// Read client response.
SmartStream.ReadLineAsyncOP readLineOP = new SmartStream.ReadLineAsyncOP(new byte[32000],SizeExceededAction.JunkAndThrowException);
//.........这里部分代码省略.........
示例9: ProcessResponse
//.........这里部分代码省略.........
// Stop timer A,B
if(m_pTimerA != null){
m_pTimerA.Dispose();
m_pTimerA = null;
// Log
if(this.Stack.Logger != null){
this.Stack.Logger.AddText(this.ID,"Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=false] timer A(INVITE request retransmission) stopped.");
}
}
if(m_pTimerB != null){
m_pTimerB.Dispose();
m_pTimerB = null;
// Log
if(this.Stack.Logger != null){
this.Stack.Logger.AddText(this.ID,"Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=false] timer B(INVITE calling state timeout) stopped.");
}
}
// 1xx response.
if(response.StatusCodeType == SIP_StatusCodeType.Provisional){
OnResponseReceived(response);
SetState(SIP_TransactionState.Proceeding);
}
// 2xx response.
else if(response.StatusCodeType == SIP_StatusCodeType.Success){
OnResponseReceived(response);
SetState(SIP_TransactionState.Accpeted);
/* RFC 6025 7.1.
When the "Accepted" state is entered, timer L MUST be set to fire in 64*T1.
*/
m_pTimerM = new TimerEx(64 * SIP_TimerConstants.T1);
m_pTimerM.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimerM_Elapsed);
m_pTimerM.Enabled = true;
// Log
if(this.Stack.Logger != null){
this.Stack.Logger.AddText(this.ID,"Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=true] timer M(2xx retransmission wait) started, will trigger after " + m_pTimerM.Interval + ".");
}
}
// 3xx - 6xx response.
else{
SendAck(response);
OnResponseReceived(response);
SetState(SIP_TransactionState.Completed);
/* RFC 3261 17.1.1.2.
The client transaction SHOULD start timer D when it enters the "Completed" state,
with a value of at least 32 seconds for unreliable transports, and a value of zero
seconds for reliable transports.
*/
m_pTimerD = new TimerEx(this.Flow.IsReliable ? 0 : 32000,false);
m_pTimerD.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimerD_Elapsed);
// Log
if(this.Stack.Logger != null){
this.Stack.Logger.AddText(this.ID,"Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=false] timer D(INVITE 3xx - 6xx response retransmission wait) started, will trigger after " + m_pTimerD.Interval + ".");
}
m_pTimerD.Enabled = true;
}
}
#endregion
#region Proceeding
示例10: SendResponse
/// <summary>
/// Sends specified response to remote party.
/// </summary>
/// <param name="response">SIP response to send.</param>
/// <exception cref="ObjectDisposedException">Is raised when this class is Disposed and this method is accessed.</exception>
/// <exception cref="ArgumentNullException">Is raised when <b>response</b> is null reference.</exception>
public void SendResponse(SIP_Response response)
{
lock(this.SyncRoot){
if(this.State == SIP_TransactionState.Disposed){
throw new ObjectDisposedException(this.GetType().Name);
}
if(response == null){
throw new ArgumentNullException("response");
}
try{
#region INVITE
/* RFC 6026 7.1. INVITE server transaction. (Udpates RFC 3261)
|INVITE
|pass INV to TU
INVITE V send 100 if TU won't in 200 ms
send response+------------+
+--------| |--------+ 101-199 from TU
| | | | send response
+------->| |<-------+
| Proceeding |
| |--------+ Transport Err.
| | | Inform TU
| |<-------+
+------------+
300-699 from TU | |2xx from TU
send response | |send response
+--------------+ +------------+
| |
INVITE V Timer G fires |
send response +-----------+ send response |
+--------| |--------+ |
| | | | |
+------->| Completed |<-------+ INVITE | Transport Err.
| | - | Inform TU
+--------| |----+ +-----+ | +---+
| +-----------+ | ACK | | v | v
| ^ | | - | +------------+
| | | | | | |---+ ACK
+----------+ | | +->| Accepted | | to TU
Transport Err. | | | |<--+
Inform TU | V +------------+
| +-----------+ | ^ |
| | | | | |
| | Confirmed | | +-----+
| | | | 2xx from TU
Timer H fires | +-----------+ | send response
- | | |
| | Timer I fires |
| | - | Timer L fires
| V | -
| +------------+ |
| | |<----+
+------->| Terminated |
| |
+------------+
*/
if(this.Method == SIP_Methods.INVITE){
#region Proceeding
if(this.State == SIP_TransactionState.Proceeding){
AddResponse(response);
// 1xx
if(response.StatusCodeType == SIP_StatusCodeType.Provisional){
this.Stack.TransportLayer.SendResponse(this,response);
OnResponseSent(response);
}
// 2xx
else if(response.StatusCodeType == SIP_StatusCodeType.Success){
this.Stack.TransportLayer.SendResponse(this,response);
OnResponseSent(response);
SetState(SIP_TransactionState.Accpeted);
/* RFC 6025 7.1.
When the "Accepted" state is entered, timer L MUST be set to fire in 64*T1.
*/
m_pTimerL = new TimerEx(64 * SIP_TimerConstants.T1);
m_pTimerL.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimerL_Elapsed);
m_pTimerL.Enabled = true;
// Log
if(this.Stack.Logger != null){
this.Stack.Logger.AddText(this.ID,"Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=true] timer L(ACK wait) started, will trigger after " + m_pTimerL.Interval + ".");
}
}
// 3xx - 6xx
else{
this.Stack.TransportLayer.SendResponse(this,response);
OnResponseSent(response);
//.........这里部分代码省略.........
示例11: Start
/// <summary>
/// Starts transaction processing.
/// </summary>
/// <exception cref="ObjectDisposedException">Is raised when this class is Disposed and this method is accessed.</exception>
/// <exception cref="InvalidOperationException">Is raised when <b>Start</b> is called other state than 'WaitingToStart'.</exception>
public void Start()
{
lock(this.SyncRoot){
if(this.State == SIP_TransactionState.Disposed){
throw new ObjectDisposedException(this.GetType().Name);
}
else if(this.State != SIP_TransactionState.WaitingToStart){
throw new InvalidOperationException("Start method is valid only in 'WaitingToStart' state.");
}
// Move processing to thread pool.
ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object state){
lock(this.SyncRoot){
#region INVITE
if(this.Method == SIP_Methods.INVITE){
/* RFC 3261 17.1.1.2.
The initial state, "calling", MUST be entered when the TU
initiates a new client transaction with an INVITE request. The
client transaction MUST pass the request to the transport layer for
transmission (see Section 18). If an unreliable transport is being
used, the client transaction MUST start timer A with a value of T1.
If a reliable transport is being used, the client transaction SHOULD
NOT start timer A (Timer A controls request retransmissions). For
any transport, the client transaction MUST start timer B with a value
of 64*T1 seconds (Timer B controls transaction timeouts).
*/
SetState(SIP_TransactionState.Calling);
try{
// Send initial request.
this.Stack.TransportLayer.SendRequest(this.Flow,this.Request,this);
}
catch(Exception x){
OnTransportError(x);
// NOTE: TransportError event handler could Dispose this transaction, so we need to check it.
if(this.State != SIP_TransactionState.Disposed){
SetState(SIP_TransactionState.Terminated);
}
return;
}
// Start timer A for unreliable transports.
if(!this.Flow.IsReliable){
m_pTimerA = new TimerEx(SIP_TimerConstants.T1,false);
m_pTimerA.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimerA_Elapsed);
m_pTimerA.Enabled = true;
// Log
if(this.Stack.Logger != null){
this.Stack.Logger.AddText(this.ID,"Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=false] timer A(INVITE request retransmission) started, will trigger after " + m_pTimerA.Interval + ".");
}
}
// Start timer B.
m_pTimerB = new TimerEx(64 * SIP_TimerConstants.T1,false);
m_pTimerB.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimerB_Elapsed);
m_pTimerB.Enabled = true;
// Log
if(this.Stack.Logger != null){
this.Stack.Logger.AddText(this.ID,"Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=false] timer B(INVITE calling state timeout) started, will trigger after " + m_pTimerB.Interval + ".");
}
}
#endregion
#region Non-INVITE
else{
/* RFC 3261 17.1.2.2.
The "Trying" state is entered when the TU initiates a new client
transaction with a request. When entering this state, the client
transaction SHOULD set timer F to fire in 64*T1 seconds. The request
MUST be passed to the transport layer for transmission. If an
unreliable transport is in use, the client transaction MUST set timer
E to fire in T1 seconds.
*/
SetState(SIP_TransactionState.Trying);
// Start timer F.
m_pTimerF = new TimerEx(64 * SIP_TimerConstants.T1,false);
m_pTimerF.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimerF_Elapsed);
m_pTimerF.Enabled = true;
// Log
if(this.Stack.Logger != null){
this.Stack.Logger.AddText(this.ID,"Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=false] timer F(Non-INVITE trying,proceeding state timeout) started, will trigger after " + m_pTimerF.Interval + ".");
}
try{
// Send initial request.
this.Stack.TransportLayer.SendRequest(this.Flow,this.Request,this);
//.........这里部分代码省略.........
示例12: Dispose
/// <summary>
/// Cleans up any resources being used.
/// </summary>
public override void Dispose()
{
lock(this.SyncRoot){
if(m_pTimer100 != null){
m_pTimer100.Dispose();
m_pTimer100 = null;
}
if(m_pTimerG != null){
m_pTimerG.Dispose();
m_pTimerG = null;
}
if(m_pTimerH != null){
m_pTimerH.Dispose();
m_pTimerH = null;
}
if(m_pTimerI != null){
m_pTimerI.Dispose();
m_pTimerI = null;
}
if(m_pTimerJ != null){
m_pTimerJ.Dispose();
m_pTimerJ = null;
}
if(m_pTimerL != null){
m_pTimerL.Dispose();
m_pTimerL = null;
}
}
}
示例13: Dispose
/// <summary>
/// Cleans up any resources being used.
/// </summary>
public override void Dispose()
{
lock(this.SyncRoot){
if(this.IsDisposed){
return;
}
// Log
if(this.Stack.Logger != null){
this.Stack.Logger.AddText(this.ID,"Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=false] disposed.");
}
// Kill timers.
if(m_pTimerA != null){
m_pTimerA.Dispose();
m_pTimerA = null;
}
if(m_pTimerB != null){
m_pTimerB.Dispose();
m_pTimerB = null;
}
if(m_pTimerD != null){
m_pTimerD.Dispose();
m_pTimerD = null;
}
if(m_pTimerE != null){
m_pTimerE.Dispose();
m_pTimerE = null;
}
if(m_pTimerF != null){
m_pTimerF.Dispose();
m_pTimerF = null;
}
if(m_pTimerK != null){
m_pTimerK.Dispose();
m_pTimerK = null;
}
if(m_pTimerM != null){
m_pTimerM.Dispose();
m_pTimerM = null;
}
this.ResponseReceived = null;
base.Dispose();
}
}
示例14: Dispose
/// <summary>
/// Cleans up any resources being used.
/// </summary>
public void Dispose()
{
lock(m_pLock){
if(m_IsDisposed){
return;
}
m_IsDisposed = true;
foreach(SIP_Flow flow in this.Flows){
flow.Dispose();
}
m_pOwner = null;
m_pFlows = null;
m_pTimeoutTimer.Dispose();
m_pTimeoutTimer = null;
}
}
示例15: Dispose
/// <summary>
/// Cleans up any resource being used.
/// </summary>
public void Dispose()
{
lock(m_pLock){
if(this.State == DNS_ClientTransactionState.Disposed){
return;
}
SetState(DNS_ClientTransactionState.Disposed);
m_pTimeoutTimer.Dispose();
m_pTimeoutTimer = null;
m_pOwner = null;
m_pResponse = null;
this.StateChanged = null;
this.Timeout = null;
}
}