Exemplo n.º 1
0
 public static RepeatThread Start(string name, Action task, Action<RepeatThread, Action> run)
 {
     RepeatThread result = new RepeatThread();
     Action wrappedTask = Error.Log.Wrap(string.Format("Thread \"{0}\" Failed.", name), () =>
         {
             try
             {
                 task.Call();
             }
             catch (System.Threading.ThreadInterruptedException) { result.End = true; }
             catch (System.Threading.ThreadAbortException) { result.End = true; }
         });
     run(result, () =>
         {
             result.Running = true;
             while (!result.End)
                 wrappedTask();
             result.Running = false;
         });
     return result;
 }
Exemplo n.º 2
0
		public virtual void Dispose()
		{
			if (this.listener.NotNull())
				this.Stop();
			if (this.listener.NotNull())
			{
				this.listener.Abort();
				this.listener.Dispose();
				this.listener = null;
				this.tcpListener = null;
			}
			if (this.activeConnections.NotNull())
			{
				this.activeConnections.Apply(c => c.Close());
				this.activeConnections = null;
			}
		}
Exemplo n.º 3
0
		public bool Start(Uri.Endpoint endPoint)
		{
			return this.Start(endPoint, action => this.listener = Parallel.RepeatThread.Start("TcpServer", action));
		}
Exemplo n.º 4
0
		public bool Run(Uri.Endpoint endPoint)
		{
			return this.Start(endPoint, action => this.listener = Parallel.RepeatThread.Run(action));
		}