本文整理汇总了C#中TimerEx.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# TimerEx.Dispose方法的具体用法?C# TimerEx.Dispose怎么用?C# TimerEx.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimerEx
的用法示例。
在下文中一共展示了TimerEx.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IDLE
//.........这里部分代码省略.........
...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);
readLineOP.Completed += new EventHandler<EventArgs<SmartStream.ReadLineAsyncOP>>(delegate(object sender,EventArgs<SmartStream.ReadLineAsyncOP> e){
try{
if(readLineOP.Error != null){
LogAddText("Error: " + readLineOP.Error.Message);
timer.Dispose();
return;
}
// Remote host closed connection.
else if(readLineOP.BytesInBuffer == 0){
LogAddText("Remote host(connected client) closed IMAP connection.");
timer.Dispose();
Dispose();
return;
}
LogAddRead(readLineOP.BytesInBuffer,readLineOP.LineUtf8);
if(string.Equals(readLineOP.LineUtf8,"DONE",StringComparison.InvariantCultureIgnoreCase)){
timer.Dispose();
m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"OK","IDLE terminated."));
BeginReadCmd();
}
else{
while(this.TcpStream.ReadLine(readLineOP,true)){
if(readLineOP.Error != null){
LogAddText("Error: " + readLineOP.Error.Message);
timer.Dispose();
return;
}
LogAddRead(readLineOP.BytesInBuffer,readLineOP.LineUtf8);
if(string.Equals(readLineOP.LineUtf8,"DONE",StringComparison.InvariantCultureIgnoreCase)){
timer.Dispose();
示例2: Start
/// <summary>
/// Starts data connection processing.
/// </summary>
/// <exception cref="ObjectDisposedException">Is raised when this is disposed and this method is accessed.</exception>
public void Start()
{
if(m_IsDisposed){
throw new ObjectDisposedException(this.GetType().Name);
}
// Passive mode, start waiting client connection.
if(m_pSession.PassiveMode){
WriteLine("150 Waiting data connection on port '" + ((IPEndPoint)m_pSession.m_pPassiveSocket.LocalEndPoint).Port + "'.");
// Start connection wait timeout timer.
TimerEx timer = new TimerEx(10000,false);
timer.Elapsed += delegate(object sender,System.Timers.ElapsedEventArgs e){
WriteLine("550 Data connection wait timeout.");
Dispose();
};
timer.Enabled = true;
m_pSession.m_pPassiveSocket.BeginAccept(
delegate(IAsyncResult ar){
try{
timer.Dispose();
m_pSocket = m_pSession.m_pPassiveSocket.EndAccept(ar);
// Log
m_pSession.LogAddText("Data connection opened.");
StartDataTransfer();
}
catch{
WriteLine("425 Opening data connection failed.");
Dispose();
}
},
null
);
}
// Active mode, connect to client data port.
else{
WriteLine("150 Opening data connection to '" + m_pSession.m_pDataConEndPoint.ToString() + "'.");
m_pSocket = new Socket(m_pSession.LocalEndPoint.AddressFamily,SocketType.Stream,ProtocolType.Tcp);
m_pSocket.BeginConnect(
m_pSession.m_pDataConEndPoint,
delegate(IAsyncResult ar){
try{
m_pSocket.EndConnect(ar);
// Log
m_pSession.LogAddText("Data connection opened.");
StartDataTransfer();
}
catch{
WriteLine("425 Opening data connection to '" + m_pSession.m_pDataConEndPoint.ToString() + "' failed.");
Dispose();
}
},
null
);
}
}