protected override void OnStop() { compressionThread.Finish(); compressionThread = null; lock (compressionAddList) { compressionAddList.Clear(); } }
protected override void OnStart() { // Open the guid file, string guidFile = Path.Combine(path, "block_server_guid"); // If the guid file exists, if (File.Exists(guidFile)) { // Get the contents, StreamReader reader = new StreamReader(guidFile, Encoding.UTF8); string firstLine = reader.ReadLine(); // Set the server guid Id = Int64.Parse(firstLine.Trim()); reader.Close(); } else { // The guid file doesn't exist, so create one now, FileStream fileStream = File.Create(guidFile); // Create a unique server_guid Random r = new Random(); int v1 = r.Next(); long v2 = DateTime.Now.Ticks; Id = (v2 << 16) ^ (v1 & 0x0FFFFFFF); // Write it out to the guid file, StreamWriter writer = new StreamWriter(fileStream); writer.WriteLine(Id); writer.Flush(); writer.Close(); } // Start the compression thread, compressionThread = new CompressionThread(this); base.OnStart(); }
protected override void OnStop() { compressionThread.Finish(); compressionThread = null; lock (compressionAddList) { compressionAddList.Clear(); } }
protected override void OnStart() { // Open the guid file, string guidFile = Path.Combine(path, "block_server_guid"); // If the guid file exists, if (File.Exists(guidFile)) { // Get the contents, StreamReader reader = new StreamReader(guidFile, Encoding.UTF8); string firstLine = reader.ReadLine(); // Set the server guid Id = Int64.Parse(firstLine.Trim()); reader.Close(); } else { // The guid file doesn't exist, so create one now, FileStream fileStream = File.Create(guidFile); // Create a unique server_guid Random r = new Random(); int v1 = r.Next(); long v2 = DateTime.Now.Ticks; Id = (v2 << 16) ^ (v1 & 0x0FFFFFFF); // Write it out to the guid file, StreamWriter writer = new StreamWriter(fileStream); writer.WriteLine(Id); writer.Flush(); writer.Close(); } // Start the compression thread, compressionThread = new CompressionThread(this); base.OnStart(); }