using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace TimeServiceClient { class Client { public bool keepClocking = true; LocalTimeProxy proxy = null; public Client() { proxy = new LocalTimeProxy(); } public void ClockingThread() { while (keepClocking) { Console.WriteLine(proxy.GetLocalTime()); Thread.Sleep(1000); } proxy.Close(); } static void Main(string[] args) { Client client = new Client(); //Create a separate thread to request the time once a second Thread thread = new Thread(new ThreadStart(client.ClockingThread)); thread.Start(); Console.WriteLine("Service is running....press any key to terminate."); Console.ReadKey(); client.keepClocking = false; //wait 2 seconds Thread.Sleep(2000); } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)