Ejemplo n.º 1
0
		public ServiceHost(int servicePort)
		{
			pools = new List<SocketPool>();
			poolsLock = new ReaderWriterLockSlim();
			container = new ServiceContainer();
			this.servicePort = servicePort;
		}
Ejemplo n.º 2
0
		static void Main(string[] args)
		{
//			var waitEvent = new ManualResetEvent(false);
//			var job = new Job2() {resetEvent = waitEvent};
//			var t = new Thread(job.Run);
//			t.Start();
//			waitEvent.WaitOne();
//			var now = DateTime.Now;
//			Console.WriteLine("Time to start again: " + now.Ticks);
			int threadCount = 1;
			var serviceContainer = new ServiceContainer();
//			var proxy = new MyRemoteServiceProxy(serviceContainer, new SocketPool(threadCount, serviceContainer, "127.0.0.1:11885"));
			var jobs = new Job[threadCount];
			var threadWaitEvent = new ManualResetEvent(false);
			var mainWaitEvents = new ManualResetEvent[threadCount];
			for (var i = 0; i < threadCount; i++)
			{
				mainWaitEvents[i] = new ManualResetEvent(false);
//				jobs[i] = new Job() {proxy = proxy, resetEvent = mainWaitEvents[i], waitEventToStart = threadWaitEvent};
				var t = new Thread(jobs[i].Run);
				t.Start();
			}
			//All thread run now
			threadWaitEvent.Set();
			//Wait all thread to finish
			WaitHandle.WaitAll(mainWaitEvents);
			long totalTime = 0;
			for (int i = 0; i < threadCount; i++)
			{
				totalTime += jobs[i].totalTime;
			}
			Console.WriteLine("Total time: " + totalTime);
			Console.ReadKey();
		}